This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use v5.22; | |
use experimental qw/ refaliasing postderef / ; | |
use Pegex; | |
my $data = do { local $/; <DATA> } ; | |
my $grammar = q[ | |
%grammar thing | |
%version 0.0.1 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Converting to both perl5 and perl6 to see differences and similarities. | |
# Note that if you have a perl > 5.14.* the -E switch enables | |
# say, unicode, etc. which makes perl5 a bit more like perl6 | |
# for oneliners anyway. Is using the -p switch cheating? | |
#------------------------------------------------------------ | |
# 1. Print the third column of the line in a file. | |
# a. | |
perl6 -n -e '.split(" ")[2].say' file.txt |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env perl | |
use 5.14.0 ; | |
use Geo::IP::PurePerl; | |
use autodie ; | |
my $gi = Geo::IP::PurePerl->new(GEOIP_STANDARD); | |
# /tmp/ips.txt is created from firewall | |
# rules and/or /var/log/auth.log with e.g. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sub escape ($str) { | |
# Puts a slash before non-alphanumeric characters | |
S:g[<-alpha -digit>] = "\\$/" given $str | |
} | |
say escape 'foo#bar?'; # foo\#bar\? | |
{ | |
sub escape ($str) { | |
# Writes each non-alphanumeric character in its hexadecimal escape |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class HangpersonGame | |
def initialize(word) | |
@word = word | |
@guesses = "" | |
@wrong_guesses = "" | |
end | |
attr_accessor :word, :guesses, :wrong_guesses | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package Surfz ; | |
use Function::Parameters ; | |
use base 'Sub::Attributes'; | |
fun new :ClassMethod { | |
my $class = shift; | |
my $self = {}; | |
bless $self, $class; | |
return $self; |