Фрагменты Perl 6 в Perl 5.10

690 views
660 views

Published on

Published in: Technology
0 Comments
0 Likes
Statistics
Notes
  • Be the first to comment

  • Be the first to like this

No Downloads
Views
Total views
690
On SlideShare
0
From Embeds
0
Number of Embeds
5
Actions
Shares
0
Downloads
1
Comments
0
Likes
0
Embeds 0
No embeds

No notes for slide

Фрагменты Perl 6 в Perl 5.10

  1. 1. Фрагменты Perl 6 в Perl 5.10
  2. 2. Фрагменты Perl 6 в Perl 5.10 и различия
  3. 3. use
feature
qw( 



say 



switch 



state );
  4. 4. use
feature
qw( 



say 



switch 



state ); use
feature
quot;:5.10quot;;
  5. 5. use
feature
qw( 



say 



switch 



state ); use
feature
quot;:5.10quot;; use
5.10.0;
  6. 6. use
feature
qw( 



say 



switch 



state ); use
feature
quot;:5.10quot;; use
v5.10.0;
  7. 7. say
  8. 8. my
$x
=
‘UPW2008’; say
$x;
  9. 9. 5.10 my
$x
=
‘UPW2008’; say
$x; UPW2008
  10. 10. 6 my
$x
=
‘UPW2008’; say
$x; UPW2008
  11. 11. 5.10 my
$x
=
‘UPW2008’; say
($x);
  12. 12. 5.10 my
$x
=
‘UPW2008’; say
($x); UPW2008
  13. 13. 6 my
$x
=
‘UPW2008’; say
($x); UPW2008
  14. 14. 6 my
$x
=
‘UPW2008’; say($x); UPW2008
  15. 15. 6 my
$x
=
‘UPW2008’; $x.say; UPW2008
  16. 16. 5.10 my
$x
=
‘UPW2008’; $x.say;
  17. 17. 6 my
$x
=
‘UPW2008’; $x.say(); UPW2008
  18. 18. 5.10 my
$x
=
‘UPW2008’; $x.say(); Undefined
subroutine
 &main::say
called
at
‐e
 line
1
  19. 19. for
(1..3)
{ 



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



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



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



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



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



.say; } 1 2 3
  25. 25. switch
  26. 26. 5.10, 6 my
$str
=
quot;YAPC::Asiaquot;;
 given
($str)
{ 



when
(/Asia/)
{ 







say
quot;Asiaquot; 



} }
  27. 27. 5.10, 6 my
$str
=
quot;YAPC::Asiaquot;;
 given
($str)
{ 



when
(/Asia/)
{ 







say
quot;Asiaquot; 



} }
  28. 28. 6 my
$str
=
quot;YAPC::Asiaquot;;
 given
($str)
{ 



when
(/Asia/)
{ 







say
quot;Asiaquot; 



} }
  29. 29. 6 my
$str
=
quot;YAPC::Asiaquot;;
 given
$str
{ 



when
/Asia/
{ 







say
quot;Asiaquot; 



} }
  30. 30. 6 my
$str
=
quot;YAPC::Asiaquot;;
 given
$str
{ 



say
quot;Asiaquot;
when
/Asia/
 }
  31. 31. state
  32. 32. sub
f
{ 


state
$c; 


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


state
$c; 


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


state
$c; 


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


state
$c; 


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


state
$c
=
0; 


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


state
$c
=
0; 


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


state
$c
=
0; 


say
++$c; } f();
f();
f(); 1
1
1
  39. 39. //
  40. 40. // defined‐or
  41. 41. my
$c
=
0; my
$d
=
$c
//
3; say
$d;










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










4
  42. 42. ~~

×