SlideShare una empresa de Scribd logo
1 de 136
Descargar para leer sin conexión
Perl 5.10
 in 2010
Part I
The History
and some
Statistics
5.10.0
18 December 2007
Today is
5 March 2010
810 days
 passed
5.10.1
exists already
5.11.0, 5.11.1,
5.11.2, 5.11.3, 5.11.4
exist already
5.12
soon
Dutch Perl Workshop 2010

Andrew Shitov
Perl 5.10 in 2010

Leon Timmermans
What's new in Perl 5.12?

Martin Berends
Perl 6 implementations in March 2010

Jonathan Worthington
Solved in Perl 6
Total on CPAN
 ~80 000 modules
Total on CPAN
~20 000 distributions
Total on CPAN
 ~8000 authors
Are Perl 5.10
features used
 frequently?
?
~ 200 modules
~ 100 authors
Part II
Perl 5.10 Features
say
   say
$x
     ==
print
"$xn"
~~
$a
~~
/d/
$a
~~
@list
@list
~~
%hash
switch
given($x)
{




when(/a/)
{...}




when('b')
{...}




default


{...}
}
state
sub
counter
{




state
$c
=
0;




return
++$c;
}
regexes
(?<name>)   %+
K          %‐
R          g<name>
//
 $city
=
$arg
//
'Moscow';

$vacancy{city}
//=
'Moscow';
Part III
Ontology
How to enable
use
5.010000;
use
5.01001;
use
5.010;
use
5.010_000;
use
5.10.0;
use
v5.10.0;
use
v5.10;
use
feature
':5.10';
5.10.0
         v5.10.0
         v5.10

vector string
version string

abbreviated — v-string
5.10.0
         v5.10.0
         v5.10

vector string
version string

abbreviated — v-string
say for debugging
given
($action)
{




when
(/^include_cmd:/)
{








my
$cmd
=
$child‐>content;








$cmd
=~
/^include_cmd:(s*)/;








my
$ws
=
$1
||
'';








$cmd
=~
s/^include_cmd:s*//;








#say("cmd:$ws$cmd");








$cmd
=
cwd()
.
'/'
.
$cmd;








@output
=
qx($cmd);








$child‐>content($ws
.
join($ws,
@output));




}


 Pod::Elemental::Transformer::Include
— 08 Jan 2010
 include output via files and commands
// and //=
for default values
$port
//=

5432;
$host
//=
'localhost';

$col

//=
'';




Pg::Loader — 07 Jul 2008
Perl extension for loading Postgres tables
$attrz{
maxjob

}
//=
1;
$value
//=
1;

$attrz{
$_
}
//=
0;
$attrz{
verbose
}
//=
'';
$attrz{
debug


}
//=
'';
$val
//=
1;
$exit
//=
0;
$skipz‐>{
$job_id
}
//=
'Skip
on
SIGHUP'




Parallel::Depend — 12 Aug 2009
Parallel-dependent dispatch of perl or shell code
sub
import


{




shift;




my
%args
=
@_;




#
we
do
not
care
about
autoviv




$^H{fixedtime}
=
$args{epoch_offset}
//






















CORE::time;
}




fixedtime — 14 Aug 2008
lexical pragma to fix the epoch offset for time related functions
say
$answer
//





"I
don't
know
enough
to
answer
you
yet.";




Hailo — 29 Jan 2010
A pluggable Markov engine analogous to MegaHAL
my
$marpa_version

=





$Parse::Marpa::VERSION
//
'undef';
my
$source_version
=





$Parse::Marpa::Source::VERSION
//
'undef';

$options
//=
{};




Parse::Marpa — 14 Dec 2008
Generate Parsers from any BNF grammar
my
$nulling_symbol
=


$rhs_symbol‐>[Parse::Marpa::Internal::Symbol::NULL_ALIAS]
//
$rhs_symbol;

$action
//=
$default_action;

say
{$trace_fh}




'Problems
compiling
action
for
original
rule:
',




Parse::Marpa::brief_original_rule($rule);

my
$clone
=
$clone_arg
//
1;
my
$current_parse_set
=
$parse_set_arg
//
$default_parse_set;

$choice
//=
0;

$lines
//=
[0];
$source_options
//=
{};




 Parse::Marpa::Internal::Evaluator
— 14 Dec 2008
 Generate Parsers from any BNF grammar
my
$trace_fh
=
$arg_trace_fh
//
(*STDERR);

my
$trace_fh
=
shift;
$trace_fh
//=
*STDERR;




Parse::Marpa::Recognizer
— 14 Dec 2008
Generate Parsers from any BNF grammar
// inside return
return
$self‐>_get_infection(
$disease‐>id
)
//
0;

my
$val
=
$self‐>_get($key)
//
$default‐>{$key};



return
@{
$self‐>_players
//
[]
};




Games::Pandemic::City,
Games::Pandemic::Config
— 07 Sep 2009
Games::Risk
— 18 Oct 2008
sub
homedir
{


my
($self)
=
@_;


require
File::HomeDir;


return
File::HomeDir‐>my_home




//
croak
'File::HomeDir
says
you
have
no
home














directory';
}




App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
sub
config_filename
{


my
($self)
=
@_;


return
$self‐>{'config_filename'}
//
do
{




require
File::Spec;




File::Spec‐>catfile









($self‐>homedir,
'.rss2leafnode.conf');


};
}




App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
return




isodate_to_rfc822($date
//
$self‐>{'now822'});

return
URI::Title::title




({
url

=>
($resp‐>request‐>uri
//
''),







data
=>
$resp‐>decoded_content








(charset
=>
'none')});




App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
return
inside //
my
$b_time
=
$self‐>item_to_timet($b_item)



//
return
$a_item;

my
$a_time
=
$self‐>item_to_timet($a_item)




//
return
$b_item;;

my
$str
=
$self‐>item_to_date($item)




//
return;




App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
return
(elt_to_email
($item‐>first_child('author'))








//
elt_to_email
($item


‐>first_child('dc:creator'))








//
elt_to_email
($item


‐>first_child('dc:contributor'))








//
non_empty
($item‐>first_child_text('wiki:username'))









//
elt_to_email
($channel‐>first_child('dc:creator'))








//
elt_to_email
($channel‐>first_child('author'))








//
elt_to_email
($channel‐>first_child('managingEditor'))








//
elt_to_email
($channel‐>first_child('webMaster'))









//
elt_to_email
($item


‐>first_child('dc:publisher'))








//
elt_to_email
($channel‐>first_child('dc:publisher'))









//
non_empty
($channel‐>first_child_text('title'))









#
RFC822








//
'nobody@'.$self‐>uri_to_host







);


App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
sub
item_to_language
{


my
($self,
$item)
=
@_;


my
$content;


my
$ret
=
(elt_to_language($item)













//
elt_to_language($item‐>first_child('content')));


for
(;;)
{




$item
=
$item‐>parent
//
last;




$ret
//=
elt_to_language($item);


}


$ret
//=
$self‐>{'resp'}‐>content_language;


return
$ret;
}




App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
Chained
//



my
$captures



=
$arg
{captures}






//
[];



my
$comment




=
escape
$arg
{comment}
//
$name
//
"";



my
$upgrade




=
$arg
{utf8_upgrade}


//
1;



my
$downgrade


=
$arg
{utf8_downgrade}
//
1;



my
$match






=
$arg
{match}









//
1;




  Games::Wumpus
— 24 Nov 2009
  Play Hunt the Wumpus
when with a scalar




while
(my
($key,
$value)
=
each
%arg)
{








given
($key)
{












when
("tests")
{
















$Test
‐>
plan
($value);












}












when
("import")
{
















$self
‐>
export_to_level
(1,
$self,
$_)
for
@{$value
||
[]};












}












default
{
















die
"Unknown
option
'$key'n";












}








}




}




   Test::Regexp
— 09 Dec 2009
   Test your regular expressions




foreach
(@hazards)
{








when
($WUMPUS)
{












$self
‐>
lose;












push
@messages
=>
"Oops!
Bumped
into
a
Wumpus!";








}








when
($PIT)
{












$self
‐>
lose;












push
@messages
=>
"YYYIIIIEEEE!
Fell
in
a
pit!";








}








when
($BAT)
{












push
@messages
=>



















"ZAP!
Super
bat
snatch!
Elsewhereville
for
you!";








}




}




   Games::Wumpus
— 24 Nov 2009
   Play Hunt the Wumpus
when for selection
given
($k)
{




when
('file')



{
$opt_file




=
$v;
}




when
('argv')



{
$opt_argv




=
$v;
}




when
('inter')


{
$opt_interact
=
$v;
}




when
('prompt')

{
$opt_prompt


=
$v;
}




when
('quiet')


{
$opt_quiet



=
$v;
}




when
('tty_in')

{
$tty_in






=
$v;
}




when
('tty_out')
{
$tty_out





=
$v;
}




default
{








die
"Error:
in
subroutine
set_opt(),
found
invalid
key
{$k
=>
'$v'}













(not
'file',
'argv',
'inter',
'prompt',
'quiet',













'tty_in'
or
'tty_out')";




}
}




Term::DBPrompt
— 18 Dec 2009
Commandline prompt for a database application
given
($inp_typ)




when
('f')
.
.
.




when
('a')
.
.
.




when
('i')
.
.
.




default
{








die
"Internal
error:
type
=
'$inp_typ'
(not
'f',
'a'
or
'i')";




}
}




Term::DBPrompt
— 18 Dec 2009
Commandline prompt for a database application
when
with a boolean value
unless
(
'itan'
~~
@list
)
{




given
(
length
$password
)
{








when
(
16
)
{












#
ok








}








when
(
$_
<
4
)
{












die('ERROR:
Password
is
too
short
(Min
4
bytes
required)');








}








when
(
$_
>
16
)
{












die('ERROR:
Password
is
too
long
(Max
16
bytes
allowed)');








}








default
{












while
(1)
{
















$password
.=
'0';
















last





















if
length
$password
==
16;












}








}




}

App::iTan::Utils
— 26 Oct 2009
Secure management of iTans for online banking
unless
(
'itan'
~~
@list
)
{




given
(
length
$password
)
{








when
(
16
)
{












#
ok








}








when
(
$_
<
4
)
{












die('ERROR:
Password
is
too
short
(Min
4
bytes
required)');








}








when
(
$_
>
16
)
{












die('ERROR:
Password
is
too
long
(Max
16
bytes
allowed)');








}








default
{












while
(1)
{
















$password
.=
'0';
















last





















if
length
$password
==
16;












}








}




}

App::iTan::Utils
— 26 Oct 2009
Secure management of iTans for online banking
when
with regular expressions
sub
range2list
{

 my
$_
=
shift;

 given
($_)
{

 
 when
(/^(d)‐(d)$/o
)


{
return
"$1..$2"
}

 
 when
(/^d..d$/o
)




{
return
"$_"
}

 
 when
(/^d$/o
)










{
return
$_}

 
 when
(/^(.*?),(.*)$/o
)


{
return
range2list($1).
','








































.range2list($2)}

 
 default


















{
return
''}

 }
}




Catalyst::Devel
when and ref




given(ref
$fdef){








when('ARRAY'){




Package::FromData
— 14 Jan 2008
generate a package with methods and variables from a data structure
when and undef
given
($1)
{




when
(undef)

{return}




when
($left)

{
$depth++;
}




when
($right)
{
$depth‐‐;
}
}




Parse::Marpa::Lex
given
($action)
{




when
(undef)
{;}



#
do
nothing
























#
Right
now
do
nothing

























#
but
find
lex_q_quote




when
('lex_q_quote')
{








$lexers[$ix]
=












[
&Parse::Marpa::Lex::lex_q_quote,















$prefix,
$suffix
];




}




Parse::Marpa::Recognizer
Nested given/when
given($name)
{




when
('stream:stream')
.
.
.




when
('challenge')
.
.
.




when
('failure')
.
.
.




when
('stream:features')
.
.
.









given(my
$clist
=
$node‐>getChildrenHash())
{












when
('starttls')
.
.
.












when('mechanisms')
.
.
.
















foreach($clist‐>{'mechanisms'}‐>


















[0]‐>getChildrenByTagName('*'))




















when($_‐>textContent()
eq
'DIGEST‐MD5'























or
$_‐>textContent()
eq
'PLAIN')












when('bind')
.
.
.












default
.
.
.




when
('proceed')
.
.
.




when
('success')
.
.
.




POE::Component::Jabber
— 22 Mar 2009
A POE Component for communicating over Jabber
given($name)
{




when
('stream:stream')
.
.
.




when
('challenge')
.
.
.




when
('failure')
.
.
.




when
('stream:features')
.
.
.








given(my
$clist
=
$node‐>getChildrenHash())
{












when
('starttls')
.
.
.












when('mechanisms')
.
.
.

















foreach($clist‐>{'mechanisms'}‐>


















[0]‐>getChildrenByTagName('*'))




















when($_‐>textContent()
eq
'DIGEST‐MD5'























or
$_‐>textContent()
eq
'PLAIN')












when('bind')
.
.
.












default
.
.
.




when
('proceed')
.
.
.





when
('success')
.
.
.




POE::Component::Jabber
— 22 Mar 2009
A POE Component for communicating over Jabber
for and when
for
(
catch
)
{


when
(
$_‐>isa('Getopt::Lucid::Exception::ARGV')
)
{




say;




#
usage
stuff




return
1;


}


default
{
die
$_
}
}




App::CPAN::Mini::Visit
— 07 Nov 2008
explore each distribution in a minicpan repository
~~
return
_fail(
$pkg,
$sub
)
if
$_
~~
0;



if
(
$attr
~~
/^Export_?Lexical$/i
)
{




Export::Lexical
— 09 Oct 2008
Lexically scoped subroutine imports
@exportz



=
grep
{
!
(
$_
~~
@argz
)
}
@_;



$disp
~~
@exportz









or
push
@exportz,
$disp;




Exporter::Proxy
— 29 Jan 2010
Simplified symbol export & proxy dispatch
@exportz



=
grep
{
!
(
$_
~~
@argz
)
}
@_;



$disp
~~
@exportz









or
push
@exportz,
$disp;
                                           Cool?




Exporter::Proxy
— 29 Jan 2010
Simplified symbol export & proxy dispatch
$disp
~~
@exportz









or
push
@exportz,
$disp;




push
@exportz,
$disp
unless
$disp
~~
@exportz
for(
@_
)




{








index
$_,
':'








or
next;









if(
$_
~~
@exportz
)








{












my
$source

=
qualify_to_ref
$_,
$source;












my
$install
=
qualify_to_ref
$_,
$caller;













*$install


=
*$source;








}








else








{












die
"Bogus
$source:
'$_'
not
exported";








}




}




Exporter::Proxy
— 29 Jan 2010
Simplified symbol export & proxy dispatch
for(
@_
)




{








index
$_,
':'








or
next;
                                                 Maybe when?








if(
$_
~~
@exportz
)








{












my
$source

=
qualify_to_ref
$_,
$source;












my
$install
=
qualify_to_ref
$_,
$caller;













*$install


=
*$source;








}








else








{












die
"Bogus
$source:
'$_'
not
exported";








}




}




Exporter::Proxy
— 29 Jan 2010
Simplified symbol export & proxy dispatch
48 files, and only single one
(Maplat::Helpers::CommandHelper)
 uses 5.10 feature
Maplat                                         Maplat::Web::Login
Maplat::Helpers::BuildNum                      Maplat::Web::LogoCache
Maplat::Helpers::CSVFilter                     Maplat::Web::MemCache
Maplat::Helpers::Cache::Memcached              Maplat::Web::MemCacheSim
Maplat::Helpers::Cache::Memcached::GetParser   Maplat::Web::PathRedirection
Maplat::Helpers::CommandHelper                 Maplat::Web::PostgresDB
Maplat::Helpers::DBSerialize                   Maplat::Web::SendMail
Maplat::Helpers::DateStrings                   Maplat::Web::SessionSettings
Maplat::Helpers::Logo                          Maplat::Web::StandardFields
Maplat::Helpers::MailLogger                    Maplat::Web::StaticCache
Maplat::Helpers::Mascot                        Maplat::Web::Status
Maplat::Helpers::Padding                       Maplat::Web::TemplateCache
Maplat::Helpers::Strings                       Maplat::Web::UserSettings
Maplat::Helpers::TextLogger                    Maplat::Web::VariablesADM
Maplat::Web                                    Maplat::Worker
Maplat::Web::BaseModule                        Maplat::Worker::AdminCommands
Maplat::Web::BrowserWorkarounds                Maplat::Worker::BaseModule
Maplat::Web::CommandQueue                      Maplat::Worker::Commands
Maplat::Web::Debuglog                          Maplat::Worker::DirCleaner
Maplat::Web::DirCleaner                        Maplat::Worker::MemCache
Maplat::Web::DocsSearch                        Maplat::Worker::OracleDB
Maplat::Web::DocsSpreadSheet                   Maplat::Worker::PostgresDB
Maplat::Web::DocsWordProcessor                 Maplat::Worker::Reporting
Maplat::Web::Errors                            Maplat::Worker::SendMail

Maplat
— 20 Jan 2010
The MAPLAT Web Framework
This Module is actually a stub (don't use it)
48 files, and only single one
 (Maplat::Helpers::CommandHelper)
  uses 5.10 feature




if($line‐>{id}
~~
%active)




 Maplat
— 20 Jan 2010
 The MAPLAT Web Framework
 This Module is actually a stub (don't use it)
Named capturing parens





my
$compiled_regex
=
qr{









G









(?<mArPa_prefix>$prefix)









(?<mArPa_match>$regex)









(?<mArPa_suffix>$suffix)





}xms;




 Parse::Marpa::Recognizer
Part IV
Antipatterns
use
5.010;
            use
feature
':5.10';




App::TemplateServer



$show_line
//=
1








if
$style
eq
'Regexp::Common';




  SmartMatch::Sugar
  Regexp-CharClasses
use
Switch;
 switch($stream‐>codec_type){
 
 
 
 case
"video"
{
 
 
 
 
 bless
$stream,
'Video::FFmpeg::AVStream::Video';
 
 
 
 
 push
@streams,
$stream;
 
 
 
 }
 
 
 
 case
"audio"
{
 
 
 
 
 bless
$stream,
'Video::FFmpeg::AVStream::Audio';
 
 
 
 
 push
@streams,
$stream;
 
 
 
 }
 
 
 
 case
"subtitle"
{
 
 
 
 
 bless
$stream,
'Video::FFmpeg::AVStream::Subtitle';
 
 
 
 
 push
@streams,
$stream;
 
 
 
 }
 
 
 
 else
{
 
 
 
 
 push
@streams,
$stream;
 
 
 
 }
 
 
 }

 use
if
$]
>=
5.011,
'deprecate';

Video::FFmpeg::AVFormat
my
$prefix
=
$symbol_prefix
//
$default_prefix;
$prefix
=
qr/$prefix/xms
if
defined
$prefix;

my
$suffix
=
$symbol_suffix
//
$default_suffix;
$suffix
=
qr/$suffix/xms
if
defined
$suffix;




Parse::Marpa::Recognizer
$isPermaLink
=




(lc($guid‐>att('isPermaLink')
//
'true')




eq
'true');




App::RSS2Leafnode
— 02 Feb 2010
post RSS feeds to newsgroups
$isPermaLink
=




(lc($guid‐>att('isPermaLink')
//
'true')




eq
'true');



say
'False'
if
length($bool_value)
==
5;
given
(
$params[0]
//
''
)
{




when
(blessed
$_
&&
$_‐>isa('Math::BigInt'))
{








$bit
=
$class‐>string2bit(shift(@params)‐>as_bin());




}




when
(m/^d+$/)
{








$bit
=
$class‐>int2bit(shift(@params));




}




when
(m/^0[bB][01]+$/)
{








$bit
=
$class‐>string2bit(shift(@params));




}




when
(m/^[$ZERO$ONE]+$/)
{








$bit
=
$class‐>bit2bit(shift(@params));




}




Bitmask::Data
— 03 Oct 2008
Handle unlimited length bitmasks in an easy and flexible way
while
(
my
(
$option,
$value
)
=
each
%{$args}
)
{





given
($option)
{









when
('rules')
{









when
('terminals')
{          








when
('trace_predefineds')
{









when
('start')
{              








when
('trace_iterations')
{









when
('academic')
{           








when
('trace_priorities')
{









when
('default_null_value')
{ 








when
('trace_completions')
{









when
('default_action')
{     








when
('location_callback')
{









when
('default_lex_prefix')
{ 








when
('opaque')
{









when
('default_lex_suffix')
{ 








when
('cycle_action')
{









when
('ambiguous_lex')
{      








when
('cycle_depth')
{









when
('strip')
{              








when
('warnings')
{









when
('trace_file_handle')
{ 








when
('code_lines')
{









when
('trace_actions')
{      








when
('allow_raw_source')
{









when
('trace_lex')
{          








when
('max_parses')
{









when
('trace_lex_tries')
{    








when
('version')
{









when
('trace_lex_matches')
{ 








when
('semantics')
{









when
('trace_values')
{       








when
('lex_preamble')
{









when
('trace_rules')
{        








when
('preamble')
{









when
('trace_strings')
{      








default
{




Parse::Marpa::Internal
my
$attrz











=
local
$que‐>{
attrib
}











=
$job2attrz{
$job_id
}











//=
$que‐>merge_attrib(
$job_id
)











;




Parallel::Depend
— 12 Aug 2009
Parallel-dependent dispatch of perl or shell code
foreach
my
$shipment
(@{$response‐>shipment})
{




say
".==========================================.";




say
"|
Shipment
$count

























|";




say
$shipment‐>serialize‐>draw;




say
"";




if
($self‐>verbose)
{








say
$shipment‐>xml‐>toString(1);




}




$count
++;
}




Parallel::Depend
— 12 Aug 2009
Parallel-dependent dispatch of perl or shell code
use
5.010000;

            print
"n";
            print
"
chaptersn";




DVD::Read
— 16 Nov 2008
libdvdread perl binding
do_something()
//
return
NOT_FOUND;
do_something()
//
return
NOT_FOUND;




is_leap_year()





?
($n
=
366)





:
($n
=
365)




;
Part V
Use cases
Part V
Use cases
and what to care about
How to enable
use
v5.10;

use
Modern::Perl;

use
common::sense;
use
feature
':5.10.1';
use
feature
':5.10';
use
feature
':5.10.1';
use
feature
':5.10';

           5.10 reads entire string
use
feature
':5.10.1';
use
feature
':5.10';

           5.10 reads entire string



use
feature
':5.10.1';
use
feature
':5.10';

           5.10.1 — first two parts only
use
feature
':5.10.1';
use
feature
':5.10';

           5.10 reads entire string



use
feature
':5.10.1';
use
feature
':5.10';

           5.10.1 — first two parts only
use
feature
':5.10.7';
use
everywhere
q(feature
':5.10');
use
MyModule;
MyModule‐>my_sub($$);
use
everywhere
q(feature
':5.10');
use
MyModule;
MyModule‐>my_sub($$);



package
MyModule;
sub
my_sub
{




say
$_[1];
}
1;
>
perl
‐E
"say
$$;"
~~ to check
if something is in the list
if
($last_name
~~
@attendees)
{...}
~~ to compare arrays
my
@a
=
(1,
3,
5);
my
@b
=
(1,
3,
5);
say
@a
~~
@b;
#
1
my
@a
=
(1,
3,





5);
my
@b
=
(1,
qr/d/,
5);
say
@a
~~
@b;
#
1




               Note, this
               is not
     element by element comparision
my
@a
=
(1,
3,





5);
my
@b
=
(1,
qr/d/,
5);
say
@a
~~
@b;
#
1




               Note, this
                  is
      element by element matching
~~ to check
command line arguments
%
./some_programme
‐‐debug
‐d
%
./some_programme
‐‐debug
‐d


say
'Debug'

if
'‐‐debug'
~~
@ARGV;
say
'Daemon'
if
'‐d'
~~
@ARGV;
%
./some_programme
‐‐debug
‐d


say
'Debug'

if
'‐‐debug'
~~
@ARGV;
say
'Daemon'
if
'‐d'
~~
@ARGV;


say
'Help'





if
/^(‐h|‐‐help)$/
~~
@ARGV;
Chained //
my
$ip
=





$ENV{X_HTTP_FORWARDED_FOR}
//




$ENV{HTTP_X_REAL_IP}






//




$ENV{REMOTE_ADDR};
my
$ip
=





$page‐>param('request_ip')
//




$ENV{X_HTTP_FORWARDED_FOR}
//




$ENV{HTTP_X_REAL_IP}






//




$ENV{REMOTE_ADDR};



         Easy to update
my
$ip
=





$ENV{HTTP_X_REAL_IP}






//




$page‐>param('request_ip')
//




$ENV{X_HTTP_FORWARDED_FOR}
//




$ENV{REMOTE_ADDR};



       Easy order control
state for counters
sub
count
{




state
$c;




return
++$c;
}


say
count();
#
1
say
count();
#
2
state
$count;
unless
($count)
{




#
SQL‐query
select
count(*)
...
}


my
$offset
=
int
rand
$count;
#
SQL‐query

#
select
...
limit
$offset,
1
for and when
use
v5.10;
my
@array
=
(1..20);
my
$count
=
0;
for(@array)
{




when(/[02468]$/)
{








$count++;




}




say;
}
say
$count;
use
v5.10;
my
@array
=
(1..20);
my
$count
=
0;
for(@array)
{




when(/[02468]$/)
{








$count++;




}




say;
}
say
$count;

#
10
use
v5.10;
my
@array
=
(1..20);
my
$count
=
0;
for(@array)
{




when(/[02468]$/)
{








$count++;




}




say;
}
say
$count;

#
10
1
use
v5.10;
                         3
my
@array
=
(1..20);
my
$count
=
0;           5
for(@array)
{            7




when(/[02468]$/)
{   9








$count++;        11




}                    13




say;                 15
}                        17
say
$count;

#
10        19
use
v5.10;
my
@array
=
(1..20);
my
$count
=
0;
for(@array)
{




when(/[02468]$/)
{








$count++;
continue;




}




say;
}
say
$count;

#
10
>
perl5.10
‐E



"say
for
1..3"



>
perl6
‐e



"say
for
1..3"
>
perl5.10
‐E
    1


"say
for
1..3"   2
                   3

>
perl6
‐e
       n


"say
for
1..3"   n
                   n
More

     A number of
fascinating and useful
    regex features
Part V.X
__END__


Andrew Shitov
andy@shitov.ru   talks.shitov.ru

Más contenido relacionado

La actualidad más candente

PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
Nick Belhomme
 

La actualidad más candente (19)

PHP 5.3
PHP 5.3PHP 5.3
PHP 5.3
 
C++ for Java Developers (JavaZone 2017)
C++ for Java Developers (JavaZone 2017)C++ for Java Developers (JavaZone 2017)
C++ for Java Developers (JavaZone 2017)
 
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
Loops and Unicorns - The Future of the Puppet Language - PuppetConf 2013
 
Perl 20tips
Perl 20tipsPerl 20tips
Perl 20tips
 
PHP traits, treat or threat?
PHP traits, treat or threat?PHP traits, treat or threat?
PHP traits, treat or threat?
 
Java Keeps Throttling Up!
Java Keeps Throttling Up!Java Keeps Throttling Up!
Java Keeps Throttling Up!
 
2021.laravelconf.tw.slides2
2021.laravelconf.tw.slides22021.laravelconf.tw.slides2
2021.laravelconf.tw.slides2
 
Scala parsers Error Recovery in Production
Scala parsers Error Recovery in ProductionScala parsers Error Recovery in Production
Scala parsers Error Recovery in Production
 
Mastering Namespaces in PHP
Mastering Namespaces in PHPMastering Namespaces in PHP
Mastering Namespaces in PHP
 
Perl Moderno
Perl ModernoPerl Moderno
Perl Moderno
 
Peek at PHP 7
Peek at PHP 7Peek at PHP 7
Peek at PHP 7
 
What's new in Perl 5.10?
What's new in Perl 5.10?What's new in Perl 5.10?
What's new in Perl 5.10?
 
Modern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl ProgrammerModern Perl for the Unfrozen Paleolithic Perl Programmer
Modern Perl for the Unfrozen Paleolithic Perl Programmer
 
effective_r27
effective_r27effective_r27
effective_r27
 
How Functions Work
How Functions WorkHow Functions Work
How Functions Work
 
The promise of asynchronous PHP
The promise of asynchronous PHPThe promise of asynchronous PHP
The promise of asynchronous PHP
 
Damien seguy php 5.6
Damien seguy php 5.6Damien seguy php 5.6
Damien seguy php 5.6
 
CLI, the other SAPI
CLI, the other SAPICLI, the other SAPI
CLI, the other SAPI
 
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
Can you upgrade to Puppet 4.x? (Beginner) Can you upgrade to Puppet 4.x? (Beg...
 

Destacado (9)

The National Library of Scotland in the 21st Century
The National Library of Scotland in the 21st CenturyThe National Library of Scotland in the 21st Century
The National Library of Scotland in the 21st Century
 
Documentation vs test about cucumber but not only for vegetarians
Documentation vs test about cucumber but not only for vegetariansDocumentation vs test about cucumber but not only for vegetarians
Documentation vs test about cucumber but not only for vegetarians
 
Flexoplex
FlexoplexFlexoplex
Flexoplex
 
Daniella Hyslop - Libraries Change Lives Designing the Third Space
Daniella Hyslop - Libraries Change Lives Designing the Third SpaceDaniella Hyslop - Libraries Change Lives Designing the Third Space
Daniella Hyslop - Libraries Change Lives Designing the Third Space
 
Giáo trình Illustrator cs6
Giáo trình Illustrator cs6Giáo trình Illustrator cs6
Giáo trình Illustrator cs6
 
The Physical Library and Regeneration - Tony Durcan
The Physical Library and Regeneration - Tony DurcanThe Physical Library and Regeneration - Tony Durcan
The Physical Library and Regeneration - Tony Durcan
 
The Physical Library and Regeneration
The Physical Library and Regeneration The Physical Library and Regeneration
The Physical Library and Regeneration
 
Flexoplex
FlexoplexFlexoplex
Flexoplex
 
Creating Edinburgh's Virtual Library
Creating Edinburgh's Virtual Library Creating Edinburgh's Virtual Library
Creating Edinburgh's Virtual Library
 

Similar a Perl 5.10 in 2010

Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
mussawir20
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
Iftekhar Eather
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
Kang-min Liu
 

Similar a Perl 5.10 in 2010 (20)

Introduction to Modern Perl
Introduction to Modern PerlIntroduction to Modern Perl
Introduction to Modern Perl
 
Advanced Perl Techniques
Advanced Perl TechniquesAdvanced Perl Techniques
Advanced Perl Techniques
 
PHP Workshop Notes
PHP Workshop NotesPHP Workshop Notes
PHP Workshop Notes
 
Whatsnew in-perl
Whatsnew in-perlWhatsnew in-perl
Whatsnew in-perl
 
DevOps in PHP environment
DevOps in PHP environmentDevOps in PHP environment
DevOps in PHP environment
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
What's new in Perl 5.14
What's new in Perl 5.14What's new in Perl 5.14
What's new in Perl 5.14
 
Php Reusing Code And Writing Functions
Php Reusing Code And Writing FunctionsPhp Reusing Code And Writing Functions
Php Reusing Code And Writing Functions
 
Introducing PHP Latest Updates
Introducing PHP Latest UpdatesIntroducing PHP Latest Updates
Introducing PHP Latest Updates
 
Introduction to PHP
Introduction to PHPIntroduction to PHP
Introduction to PHP
 
PHP 7
PHP 7PHP 7
PHP 7
 
Perl 5.10
Perl 5.10Perl 5.10
Perl 5.10
 
PHP: The easiest language to learn.
PHP: The easiest language to learn.PHP: The easiest language to learn.
PHP: The easiest language to learn.
 
Php
PhpPhp
Php
 
Perl Tidy Perl Critic
Perl Tidy Perl CriticPerl Tidy Perl Critic
Perl Tidy Perl Critic
 
Good Evils In Perl
Good Evils In PerlGood Evils In Perl
Good Evils In Perl
 
SymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performancesSymfonyCon 2017 php7 performances
SymfonyCon 2017 php7 performances
 
Dealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter ScottDealing with Legacy Perl Code - Peter Scott
Dealing with Legacy Perl Code - Peter Scott
 
Giới thiệu PHP 7
Giới thiệu PHP 7Giới thiệu PHP 7
Giới thiệu PHP 7
 
Flying under the radar
Flying under the radarFlying under the radar
Flying under the radar
 

Último

+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
?#DUbAI#??##{{(☎️+971_581248768%)**%*]'#abortion pills for sale in dubai@
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Victor Rentea
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Safe Software
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
WSO2
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
panagenda
 

Último (20)

Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​Elevate Developer Efficiency & build GenAI Application with Amazon Q​
Elevate Developer Efficiency & build GenAI Application with Amazon Q​
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
Apidays New York 2024 - The Good, the Bad and the Governed by David O'Neill, ...
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024Finding Java's Hidden Performance Traps @ DevoxxUK 2024
Finding Java's Hidden Performance Traps @ DevoxxUK 2024
 
CNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In PakistanCNIC Information System with Pakdata Cf In Pakistan
CNIC Information System with Pakdata Cf In Pakistan
 
Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)Introduction to Multilingual Retrieval Augmented Generation (RAG)
Introduction to Multilingual Retrieval Augmented Generation (RAG)
 
Six Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal OntologySix Myths about Ontologies: The Basics of Formal Ontology
Six Myths about Ontologies: The Basics of Formal Ontology
 
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers:  A Deep Dive into Serverless Spatial Data and FMECloud Frontiers:  A Deep Dive into Serverless Spatial Data and FME
Cloud Frontiers: A Deep Dive into Serverless Spatial Data and FME
 
Architecting Cloud Native Applications
Architecting Cloud Native ApplicationsArchitecting Cloud Native Applications
Architecting Cloud Native Applications
 
presentation ICT roal in 21st century education
presentation ICT roal in 21st century educationpresentation ICT roal in 21st century education
presentation ICT roal in 21st century education
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Exploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with MilvusExploring Multimodal Embeddings with Milvus
Exploring Multimodal Embeddings with Milvus
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectorsMS Copilot expands with MS Graph connectors
MS Copilot expands with MS Graph connectors
 
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ..."I see eyes in my soup": How Delivery Hero implemented the safety system for ...
"I see eyes in my soup": How Delivery Hero implemented the safety system for ...
 
Why Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire businessWhy Teams call analytics are critical to your entire business
Why Teams call analytics are critical to your entire business
 
How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
Apidays New York 2024 - Accelerating FinTech Innovation by Vasa Krishnan, Fin...
 

Perl 5.10 in 2010