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
diff -r MyWeb-App/lib/MyWeb/App.pm MyWeb-App-2/lib/MyWeb/App.pm | |
3c3 | |
< | |
--- | |
> set serializer => 'JSON'; | |
9a10,14 | |
> post '/test/' => sub { | |
> my $data = from_json( param('json'), {utf8 => 0}); | |
> return { msg => $data->{q} } | |
> }; |
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 warnings; | |
my @comparanda; | |
my @similar; | |
my $opts = {}; | |
@similar = grep { 0 == ($a->{$opts->{'name'}} cmp $b->{$opts->{'name'}}) } @comparanda; # case 1 - this is what I mean | |
@similar = grep { (0 == $a->{$opts->{'name'}}) cmp $b->{$opts->{'name'}} } @comparanda; # case 2 - I can see why perl might think this | |
@similar = grep { 0 == $a->{$opts->{'name'}} cmp $b->{$opts->{'name'}} } @comparanda; # case 3 is either 1 or 2 |
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 warnings; | |
my @LINES = qw(artichoke beetroot cabbage); | |
while (my $in = shift(@LINES)) { | |
my $results = []; | |
sub result { | |
push @$results, shift; | |
} | |
result(uc $in); |
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 warnings; | |
use List::Util qw(reduce); | |
my @in = (1,2,3,4,5,6,8,9,10,12,16,17,18,21); | |
print join (',', | |
map { defined $_->[1] ? "$_->[0]..$_->[-1]": $_->[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
#!perl -w | |
my $hashref = { | |
# | |
# POD may not appear here | |
# | |
p => sub{ | |
=pod |
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
#!perl -w | |
=head1 NAME | |
pl2py.pl | |
=head1 DESCRIPTION | |
Attempts to convert perl scripts to python with the awesome power of regular expressions. |
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 Acme::Object::Overloaded; | |
use overload '""' => sub{ 'String' }, '0+' => sub{ 123 }, 'fallback' => '0+'; | |
sub new{ | |
bless {}, shift; | |
} | |
1; | |
package main; |
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 warnings; | |
use 5.010; | |
{ | |
package A; | |
our $hash={1=>'i',2=>'j'}; | |
} | |
{ |
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
no less; use strict; use warnings; | |
open (my $fhIN, '<', $0) or die; my @lines = <$fhIN>; | |
open (my $fhOUT, '>', $0) or die; | |
print $fhOUT sort {$a cmp $b} @lines; |
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
#!perl | |
use strict; | |
use warnings; | |
use Test::More; | |
sub first_or_all { | |
return @_ if wantarray; | |
return shift; | |
} |
OlderNewer