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
# モンキーパッチングは万人におすすめできる手法とは思えないのでやらないほうがいいと思うなぁ - lestrrat | |
# http://d.hatena.ne.jp/bingo_nakanishi_perl/20090711/1247331243 | |
package Bar; | |
use Moose; | |
has name => (is => 'ro'); | |
sub say { | |
my $self = shift; | |
print $self->name, "です\n"; |
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
# モンキーパッチングは万人におすすめできる手法とは思えないのでやらないほうがいいと思うなぁ - lestrrat | |
# http://d.hatena.ne.jp/bingo_nakanishi_perl/20090711/1247331243 | |
package Bar; | |
use Moose; | |
has name => (is => 'ro'); | |
sub say { | |
my $self = shift; | |
print $self->name, "です\n"; |
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
# モンキーパッチングは万人におすすめできる手法とは思えないのでやらないほうがいいと思うなぁ - lestrrat | |
# http://d.hatena.ne.jp/bingo_nakanishi_perl/20090711/1247331243 | |
package Bar; | |
use strict; | |
sub new { | |
my($class, %args) = @_; | |
return bless { %args }, $class; | |
} |
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 strict; | |
use Math::Trig; | |
my $count = 0; | |
my $x = 0; | |
while ($count++ < 100) { | |
print int( cos( ($x / 2) * pi) ), "\n"; | |
$x < 3 ? $x++ : ($x = 0); |
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 strict; | |
sub foo { | |
warn "foo called with @_"; | |
} | |
sub call_func { | |
my $func = shift; | |
$func->( "a", "b", "c" ); |
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 strict; | |
use POE; | |
POE::Session->create( | |
inline_states => { | |
_start => sub { | |
my ($kernel) = @_[ KERNEL ]; | |
$kernel->yield('tick', "Start!",); | |
}, | |
tick => sub { |
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 Hoge; | |
use strict; | |
sub new { | |
my ($class, %args) = @_; | |
$args{hoge} ||= 'unko'; | |
return bless \%args, $class; | |
} | |
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
package Hoge; | |
use Moose; | |
has hoge => (is => 'rw', default => 'unko'); | |
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
package Hoge; | |
use Moose; | |
has hoge => (is => 'rw', default => 'unko'); | |
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
my @last_days = (31, undef, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31); | |
sub is_leap_year { | |
my $year = shift; | |
return 0 if $year % 4; | |
return 1 if $year % 100; | |
return 0 if $year % 400; | |
return 1; | |
} |