Perl 5.10

Loading...

Flash Player 9 (or above) is needed to view presentations.
We have detected that you do not have it on your computer. To install it, go here.

0 comments

Post a comment

    Post a comment
    Embed Video
    Edit your comment Cancel

    Favorites, Groups & Events

    Perl 5.10 - Presentation Transcript

    1. Perl 5.10
    2. Versions of Perl (perlhist) 5.000 17 October 1994 22 March 2000 5.6.0 18 July 2002 5.8.0 31 January 2006 5.8.8 18 December 2008 5.10
    3. Versions of Perl (perlhist) 5.000 17 October 1994 22 March 2000 5.6.0 18 July 2002 5.8.0 31 January 2006 5.8.8 18 December 2008 5.10 ? 6.0
    4. Versions of Perl (perlhist) 5.000 17 October 1994 22 March 2000 5.6.0 18 July 2002 5.8.0 31 January 2006 5.8.8 18 December 2008 5.10 Сhristmas 6.0
    5. Versions of Perl (perlhist) 5.000 17 October 1994 22 March 2000 5.6.0 18 July 2002 5.8.0 31 January 2006 5.8.8 18 December 2008 5.10 2000 6.0
    6. use
feature
    7. use
feature
qw( 



say 



switch 



state );
    8. use
feature
qw( 



say 



switch 



state ); use
feature
\":5.10\";
    9. use
feature
qw( 



say 



switch 



state ); use
feature
\":5.10\"; use
5.10.0;
    10. use
feature
qw( 



say 



switch 



state ); use
feature
\":5.10\"; use
v5.10.0;
    11. #!/perl5.10/bin/perl use
feature
\"***\";
    12. #!/perl5.10/bin/perl use
feature
\"say\"; say
\"Perl
6?\";
    13. #!/perl5.10/bin/perl use
feature
\"say\"; say
\"Perl
6?\"; no
feature
\"say\";
    14. >
perl5.10
‐e
\\ 

\"use
feature
qw(say);
say
$$;\"
    15. >
perl5.10
‐e
\\ 

\"use
feature
qw(say);
say
$$;\" >
perl5.10
‐E
\"say
$$;\"
    16. // defined‐or
    17. my
$a; my
$b
=
$a
//
2; say
$b;










2
    18. my
$c
=
0; my
$d
=
$c
//
3; say
$d;










0 my
$e
=
0; my
$f
=
$e
||
4; say
$f;










4
    19. my
$_;
    20. for
(1..5)
{ 



my
$_
=
'*'; 



print; }














*****
    21. $::_
    22. for
(1..5)
{ 



my
$_
=
'*'; 



print
$::_; }














12345
    23. our
$_;
    24. for
(1..5)
{ 



our
$_
=
'*'; 



print
$::_; }














*****
    25. use
strict
'refs'; my
$x
=
'***'; print
1
if
defined
$$x;
    26. use
strict
'refs'; my
$var
=
'***'; print
defined
$$var 



?
'yes'
:
'no'; >
perl5.8.8
test.pl no

















    27. use
strict
'refs'; my
$var
=
'***'; print
defined
$$var 



?
'yes'
:
'no'; >
perl5.10
test.pl Can't
use
string
(\"xxx\")
as
a
 SCALAR
ref
while
\"strict
refs\"
 in
use
at
test.pl
line
3.






 

    28. use
feature
'switch';
    29. use
feature
qw(switch
say); my
$tag
=
'hrpw2008'; given
($tag)
{ 



when
('hrpw2008')
{ 







say
'Yes'; 



} }
    30. use
feature
qw(switch
say); my
$tag
=
'hrpw2008'; given
($tag)
{ 



when
('hrpw2008')
{ 







say
'Yes'; 



} 



default
{say
'No';} }
    31. when
(123) when
($value) when
(undef) when
([2001..2100]) when
(/\\d+/)
    32. when
($_
>
0) when
(int) when
(int
$_) when
(\\&test_the_value) when
(test_the_value($_))
    33. given
('hrpw2008')
{ 



when
(/\\d+/)
{ 







say
'digits'; 







continue; 



} 



when
(/perl/i)
{ 







say
'Perl'; 



} }
    34. when
($what) == when
($_
~~
$what)
    35. $left
~~
$right == $right
~~
$left
    36. use
feature
'state';
    37. sub
counter{ 



state
$value
=
0; 



$value++; 



say
$value; } counter();












1 counter();












2 counter();












3
    38. Regular Expressions
    39. Named saving parens my
$date
=
'Thu
15
April
2008'; $date
=~
/ 



(










\\w+

)



\\s+ 



(










\\d+

)



\\s+ 



(










\\w+

)



\\s+ 



(










\\d{4}) /x; say
$1;


















Thu say
$4;


















2008
    40. Named saving parens my
$date
=
'Thu
15
April
2008'; $date
=~
/ 



(?<wday>



\\w+

)



\\s+ 



(?<day>




\\d+

)



\\s+ 



(?<month>


\\w+

)



\\s+ 



(?<year>



\\d{4}) /x; say
$+{wday};












Thu say
$+{year};












2008
    41. Named saving parens my
$date
=
'Thu
15
April
2008'; $date
=~
s/ 






(?<year>\\d{4}) 



/ 







$+{year}
+
1 



/xe; say
$date;







Thu
15
April
2009
    42. my
$code
=
'my
$value
=
100;
say
$value;'; $code
=~
s/ 



my

























\\s* 



(?<variable>



\\$[a‐z]+)


\\s* 



=


























\\s* 



(?<value>






[^;]+


)


\\s* 



;


























\\s* 



 



(?<other_code>.*?) 



 



(\\k<variable>) 



 



/$+{other_code}$+{value}/x; say
$code;


























say
100;
    43. my
$leap_years
=
'1992
1996
2004
2008'; $leap_years
=~
m/ 



( 







?<year>



1



\\d{3} 



) 



\\s* 



( 







?<year>



2



\\d{3} 



) /x; say
$_
for
@{$‐{year}};










1996 

































2004
    44. my
$leap_years
=
'1992
1996
2004
2008'; $leap_years
=~
m/ 



( 







?<year>



1



\\d{3} 



) 


 /gx; say
$_
for
@{$‐{year}};










1992
    45. my
$leap_years
=
'1992
1996
2004
2008'; $leap_years
=~
m/ 



( 







?<year>



1



\\d{3}


\\s* 



)+ 


 /gx; say
$_
for
@{$‐{year}};










1996
    46. use
feature
'say'; my
$expr
=
'1
+
(2
+
(3
+
(4
+
5)
+
6))'; $expr
=~
s/ 



\\( 











( 















[^()]+ 











) 











 







| 











(?1) 



\\) 



/say
$1;/xge;
    47. Posessive quantifiers ?+ *+ ++ {min,
max}+
    48. / 

\" 



(?: 








[^\"\\\\]++ 






| 








\\\\. 



)*+ 

\" /x
    49. (?|
...)
    50. my
$re
=
qr/ 





(\\d{4})(\\d\\d)(\\d\\d) 


| 





(\\w+),\\s*(\\d{4})) /x; '20080415'
=~
$re; say
\"$1
.
$2
.
$3\"; 'April,
2008'
=~
$re; say
\"$4
.
$5\";
    51. my
$re
=
qr/ 


(?|(\\d{4})(\\d\\d)(\\d\\d) 


| 





(\\w+),\\s*(\\d{4}))) /x; '20080415'
=~
$re; say
\"$1
.
$2
.
$3\"; 'April,
2008'
=~
$re; say
\"$1
.
$2\";
    52. \\g{N} \\gN
    53. \\g{‐N}
    54. \\k<named> == \\g{named}
    55. \\K
    56. \\v \\h
    57. \\V \\H
    58. \\R
    59. \\R (?> 





\\x0D\\x0A? 


| 





[ 








\\x0A‐\\x0C 








\\x85 








\\x{2028} 








\\x{2029} 





] )
    60. Smart matching ~~
    61. $a
~~
$b == $b
~~
$a
    62. my
$b; $b
~~
undef !defined
$b
    63. my
$c
=
'abc'; $c
~~
'abc' $c
eq
'abc'
    64. my
$c
=
'abc'; $c
~~
/b/ $c
=~
/b/
    65. my
@a
=
(1..3); my
@b
=
(1..3); @a
~~
@b 1
==
1
&&
2
==
2
&&
3
==
3
    66. my
@a
=
(1..3); my
@b
=
(1..3); my
@c
=
(3..5); @a
~~
@c 1
==
3
&&
2
==
4
&&
3
==
5
    67. my
@d
=
(123,
'abc'); my
@e
=
(qr/\\d/,
qr/\\w/); @d
~~
@e 123
~~
/\\d/
&& 'abc'
~~
/\\w/
    68. my
@f
=
('a'..'f'); @f
~~
'd' grep
{$_
eq
'd'}
@f
    69. my
@g
=
(1..10); @g
~~
7 grep
{$_
==
7}
@g
    70. my
@g
=
(1..10); @g
~~
7.0 grep
{$_
==
7.0}
@g
    71. my
@g
=
(1..10); @g
~~
'7.0' grep
{$_
eq
'7.0'}
@g
    72. my
@g
=
(1..10); @g
~~
/^\\d$/ grep
{$_
=~
/^\\d$/}
@g
    73. 3.14
~~
'3.14' 3.14
==
'3.14'
    74. 3.14
~~
'3.14%' 3.14
==
'3.14%'
    75. sub
subA
{return
2} sub
subB
{return
2} subA
~~
subB subA()
==
subB()
    76. sub
subA
{return
2} my
$subA1_ref
=
\\&subA; my
$subA2_ref
=
\\&subA; $subA1_ref
~~
$subA2_ref $subA1_ref
==
$subA2_ref
    77. sub
subA
{return
2} my
$subA_ref
=
\\&subA; $a
~~
$subA_ref $subA_ref‐>($a)
    78. sub
subA
{return
2} my
$subA_ref
=
\\&subA; ‐1
~~
$subA_ref $subA_ref‐>(‐1)
    79. my
%h
=
(a
=>
'alpha', 








b
=>
'beta'); %h
~~
'a' exists
$h{'a'}
    80. my
%h
=
(a
=>
'alpha', 








b
=>
'beta'); my
@f
=
('a'..'f'); %h
~~
@f grep
{$_}
@h{@f}
    81. my
%h
=
(a
=>
'alpha', 








b
=>
'beta'); %h
~~
/[A‐F]/i grep
{/[A‐F]/i}
keys
%h
    82. my
%h
=
(a
=>
'alpha', 








b
=>
'beta'); my
%hh
=
(b
=>
1,
a
=>
2); %h
~~
%hh [sort
keys
%h]
~~ [sort
keys
%hh]
    83. Elements of Perl 6 in Perl 5.10
    84. Elements of Perl 6 in Perl 5.10 and differencies
    85. say
    86. my
$x
=
'HRPW2008'; say
$x;
    87. 5.10 my
$x
=
'HRPW2008'; say
$x; HRPW2008
    88. 6 my
$x
=
'HRPW2008'; say
$x; HRPW2008
    89. 5.10 my
$x
=
'HRPW2008'; say
($x);
    90. 5.10 my
$x
=
'HRPW2008'; say
($x); HRPW2008
    91. 6 my
$x
=
'HRPW2008'; say
($x); HRPW2008
    92. 6 my
$x
=
'HRPW2008'; say($x); HRPW2008
    93. 6 my
$x
=
'HRPW2008; $x.say; HRPW2008
    94. 5.10 my
$x
=
'HRPW2008'; $x.say;
    95. 5.10 my
$x
=
'HRPW2008'; $x.say; String concatenation!
    96. 6 my
$x
=
'HRPW2008'; $x.say(); HRPW2008
    97. $_
    98. for
(1..3)
{ 



say; }
    99. 5.10 for
(1..3)
{ 



say; } 1 2 3
    100. 6 for
(1..3)
{ 



say; } \\n \\n \\n
    101. 6 for
(1..3)
{ 



say
$_; } 1 2 3
    102. 6 for
(1..3)
{ 



$_.say; } 1 2 3
    103. 6 for
(1..3)
{ 



.say; } 1 2 3
    104. switch
    105. 5.10, 6 my
$str
=
\"YAPC::Asia\";
 given
($str)
{ 



when
(/Asia/)
{ 







say
\"Asia\" 



} }
    106. 5.10, 6 my
$str
=
\"YAPC::Asia\";
 given
($str)
{ 



when
(/Asia/)
{ 







say
\"Asia\" 



} }
    107. 6 my
$str
=
\"YAPC::Asia\";
 given
($str)
{ 



when
(/Asia/)
{ 







say
\"Asia\" 



} }
    108. 6 my
$str
=
\"YAPC::Asia\";
 given
$str
{ 



when
/Asia/
{ 







say
\"Asia\" 



} }
    109. 6 my
$str
=
\"YAPC::Asia\";
 given
$str
{ 



say
\"Asia\"
when
/Asia/
 }
    110. state
    111. sub
f
{ 


state
$c; 


say
++$c; }
    112. sub
f
{ 


state
$c; 


say
++$c; } f();
f();
f();
    113. 5.10 sub
f
{ 


state
$c; 


say
++$c; } f();
f();
f(); 1
2
3
    114. 6 sub
f
{ 


state
$c; 


say
++$c; } f();
f();
f(); 1
2
3
    115. sub
f
{ 


state
$c
=
0; 


say
++$c; } f();
f();
f();
    116. 5.10 sub
f
{ 


state
$c
=
0; 


say
++$c; } f();
f();
f(); 1
2
3
    117. pugs sub
f
{ 


state
$c
=
0; 


say
++$c; } f();
f();
f(); 1
1
1
    118. Croatian Perl Workshop, Zagreb, 2008 __END__ Andrew Shitov mail@andy.sh | http://andy.sh
    SlideShare Zeitgeist 2009

    + andy.shandy.sh Nominate

    custom

    279 views, 0 favs, 0 embeds more stats

    More info about this document

    © All Rights Reserved

    Go to text version

    • Total Views 279
      • 279 on SlideShare
      • 0 from embeds
    • Comments 0
    • Favorites 0
    • Downloads 12
    Most viewed embeds

    more

    All embeds

    less

    Flagged as inappropriate Flag as inappropriate
    Flag as inappropriate

    Select your reason for flagging this presentation as inappropriate. If needed, use the feedback form to let us know more details.

    Cancel
    File a copyright complaint
    Having problems? Go to our helpdesk?

    Categories

    Tags