10. print''.join('%(pre)s%(num)s %(bot)s on the wall, %(nul)s %(bot)s,n%(tak)sn'%(lambda c,b:{'pre'
:['','%s %s on the wall.nn'%(c,b)][abs(cmp(c,'Ninety-nine'))],'num':c,'nul':c.
lower(),'bot':b,'tak':['Go to the store and buy some more... Ninety-nine %s.'%b,'Take one down, pass it around,']
[abs(cmp(x,0))] })((lambda x,o:[(['Twenty','Thirty','Forty','Fifty','Sixty','Seventy','Eighty','Ninety'
][x/(2*3+4)-2]+'-'+o.lower()).replace('-no more',''),o][int(x<20)])(x,['No more','One','Two','Three','Four','Five',
'Six','Seven','Eight','Nine','Ten','Eleven','Twelve','Thirteen','Fourteen',‘Fifteen','Sixteen','Seventeen','Eighteen',
'Nineteen'][[x,x%10][int(x>=20)]]),'bottle%s of beer'%['','s'][abs(cmp(x,1))]) for x in xrange(99,-1,-1))
45. my $eyes = "closed";
my $heart = "aching";
my $beloved = "gone";
!
!
no warnings;
!
my $love = ();
!
!
open MY, "mind";
foreach ($love) {
open MY, $eyes;
tell my $mind or open my $eyes;
}
!
do not $fear and do not die;
!
$i; die "because i love youn";
!
do { $i; sleep($_) } while ( $awake );
!
warn "$me" if ($i == $wrong);
!
bind my $love, $dear and do not exit;
for (my $world = "dark") {};
for (my $eyes = "blind") {};
77. use autodie;
open my $fh, '<', 'arquivo.txt';
!
while (my $linha = <$fh>) {
print $linha;
}
close $fh;
78. use autodie;
open my $fh, ‘>', 'arquivo.txt';
!
print $fh 'Alô, mundo!';
!
close $fh;
79. use Net::Twitter::Search;
!
my $busca = Net::Twitter::Search->new;
!
$busca->search(‘Perl')->{results};
!
foreach my $result ( @$busca ) {
say $result->{text};
}
80. !
use WWW::Mechanize;
my $mech = WWW::Mechanize->new;
!
$mech->get( 'http://www.exemplo.com' );
!
$mech->follow_link( text => 'download' );
!
$mech->submit_form( with_fields => {
nome => 'Meu Nome’,
linguagem => ‘Perl!',
});
81. !
use Spreadsheet::Read;
!
# planilha pode ser em .csv, .xls, .ods, .sxc...
my $data = ReadData( 'data.xlsx' );
!
# primeira planilha, campo A3
say $sheet->[1]{'A3'};
82. use Dancer;
!
get ‘/:nome' => sub {
“Olá, ". param(‘nome');
};
!
!
start;
83. use Dancer;
use DateTime;
!
get '/friday13' => sub {
is_friday_the_13th( DateTime->now );
};
!
get '/friday13/:year/:month/:day' => sub {
my $date = DateTime->new(
year => param('year' ),
month => param('month'),
day => param('day' ),
);
!
is_friday_the_13th( $date );
};
!
sub is_friday_the_13th {
my $date = shift;
!
if ($date->day == 13 and $date->day_name eq 'Friday') {
return ‘YES!';
}
else {
return 'NO :(';
}
}
!
start;