View Point_classic_moose.pl
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 Point; | |
use Moose; | |
has x => ( isa => 'Int', is => 'rw' ); | |
has y => ( isa => 'Int', is => 'rw' ); | |
sub negated { | |
my $self = shift; | |
$self->new( x => -$self->x, y => -$self->y ); |
View Point_neo_moose.pl
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
use MooseX::Declare; | |
class Point { | |
has x => ( isa => 'Int', is => 'rw' ); | |
has y => ( isa => 'Int', is => 'rw' ); | |
method negated { $self->new( x => -$self->x, y => -$self->y ) } | |
method transpose { $self->new( x => $self->y, y => $self->x ) } |
View Point_neo_moose2.pl
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
use MooseX::Declare; | |
role DoesNegated { | |
method negated { $self->new( x => -$self->x, y => -$self->y ) } | |
} | |
role DoesTranspose { | |
method transpose { $self->new( x => $self->y, y => $self->x ) } | |
} |
View Animal.pl
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/local/bin/perl | |
{ | |
package Animal; | |
use Moose; | |
has extinct => ( isa => 'Bool', is => 'rw' ); | |
no Moose; | |
} |
View Url.pm
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 Url; | |
use Modern::Perl; | |
use Devel::Declare (); | |
use LWP::Simple (); | |
use base 'Devel::Declare::Context::Simple'; | |
sub import { | |
my $class = shift; | |
my $caller = caller; | |
my $ctx = __PACKAGE__->new; |
View meta_perl6.pl
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 perl6 | |
# see: | |
# * http://transfixedbutnotdead.com/2010/01/13/anyone_for_metaprogramming/ | |
# * http://transfixedbutnotdead.com/2010/01/14/anyone-for-perl-6-metaprogramming/ | |
# * http://fingernailsinoatmeal.com/post/292301859/metaprogramming-ruby-vs-javascript | |
# * http://transfixedbutnotdead.com/2010/10/31/perl6-metaprogramming-update/ | |
# below runs on Rakudo Star (2010.10 release). |
View meta_programming.io
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 io | |
# see: http://transfixedbutnotdead.com/2010/01/14/anyone-for-perl-6-metaprogramming/ | |
# http://gist.github.com/276591 | |
Ninja := Object clone do ( | |
name ::= nil | |
) | |
drew := Ninja clone setName ("Drew") |
View camping_email_in_perl5
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 | |
SIX (UNIMPRESSIVE) ;# Markdown version: | |
REASONS CAMPING IS BETTER ;# 1) Download this email | |
THAN YOU WOULD IMAGINE ;# 2) ruby email.rb | |
$reasons->push(COMMUNITY, q% | |
Yes, Sinatra has a big community, but Camping definitely has a great | |
community too. Size doesn't always matter. Because there are so few users, | |
it means every single issue gets full attention. |
View gist:487366
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.012; | |
use warnings; | |
use autodie; | |
# quick & crude example for comment in: | |
# http://stackoverflow.com/questions/3308149/perl-function-knowing-receiver-type/3308591#3308591 | |
{ |
View infix.pl
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 | |
# custom infix operators in perl | |
# see "Infix operators in Python" - http://code.activestate.com/recipes/384122/ | |
# - http://news.ycombinator.com/item?id=1606155 | |
use 5.012; | |
use warnings; | |
{ |
OlderNewer