24. given - when - default
given ($foo) {
when (1) { say quot;$foo == 1quot; }
when ([2,3]) {
say quot;$foo == 2 || $foo == 3quot;
}
when (/^a[bc]d$/) {
say quot;$foo eq 'abd' || $foo eq 'acd'quot;
}
when ($_ > 100) { say quot;$foo > 100quot; }
default { say quot;None of the abovequot; }
}
62. Perl (5) is not like other Object Oriented Languages... does
NOT have an OO built-in
That's why you should learn perl if you want to learn OO!
You can learn how to make an object system, not just how
to use it.
Dan Kogai
63. package Point;
use Moose;
has 'x' => (is => 'rw', isa => 'Int');
has 'y' => (is => 'rw', isa => 'Int');
sub clear {
my $self = shift;
$self->x(0);
$self->y(0);
}
89. How it works
• you define “declarator” keywords
• it let compiler stop at the keywords
• your code parse the current line in your
way, maybe re-write it
• you re-place current line with the new
version
• it resumes the compiler on the current line