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 ); |
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 ) } |
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 ) } | |
} |
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; | |
} |
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; |
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). |
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") |
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. |
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 | |
{ |
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