Perl 5.16 new features

34,755 views

Published on

Perl 5.16 new features, YAPC::Russia «May Perl + Perl Mova» Kiev, 12–13 May 2012

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

No Downloads
Views
Total views
34,755
On SlideShare
0
From Embeds
0
Number of Embeds
27,177
Actions
Shares
0
Downloads
10
Comments
0
Likes
1
Embeds 0
No embeds

No notes for slide

Perl 5.16 new features

  1. 1. Perl 5.16 new featuresPerl Mova Kiev, Ukraine Pavel Vlasov, 2012
  2. 2. Content1.Perl 5.16 coming2.Unicode features3.Other features4.New documentation5.Performance
  3. 3. 1. Perl 5.16 coming• Development of Perl 5 (1994 – now) - 18 years• Release date of Perl 5.16 - 16 may 2012 (in next few days)
  4. 4. 1. Perl 5.16 coming• Perl 5.14 – 14 may 2011• Perl 5.16 – 16 may 2012…....• Perl 5.30 – 30 may 2026• Perl 5.32 - ?????
  5. 5. 2. Unicode features • fc (fold case) • quotameta • unicode_eval • evalbytes
  6. 6. 2. Fold case• Compare strings non-unicodeuc($string1) eq = uc($string2)$string1 = ‘A’; $string2 = ‘a’;uc(‘A’) = A uc(‘a) =AResult: OK$string1 = ‘ß’;uc(‘ß’) = ‘SS’It’s NOT OK
  7. 7. 2. Fold case• Compare strings in unicode use feature ‘fc’; fc($unicode1) eq fc($unicode2)• Use casefolding• inside a double-quoting string - "F$variable"
  8. 8. 2. quotameta• In Perl 5.16 adopted a Unicode-defined strategy for quoting non-ASCII characters my $string = ‘Perl May 2011 in Moscow; my $substr = ‘May.*?Moscow; $string =~ s{Q$substrE}{Mova 2012 in Kiev};• Or: use feature ‘unicode_strings’; my $string = ‘Perl May 2011 in Moscow; my $substr = ‘May.*?Moscow; my $quoted_substr = quotemeta($substr); $string =~ s{$quoted_substr}{Mova 2012 in Kiev};
  9. 9. 2. unicode_eval, evalbytesunicode_eval default feature of Perl 5.16 eval – evaluate string of charactersevalbytes – die if the string contains any characters outside the 8-bit range
  10. 10. 3. Other features• current sub __SUB__• CORE namespace• array base• debugger
  11. 11. 3. Current sub• current_sub (__SUB__) - reference to the current subroutine or undef outside of subroutine• easier to write recursive closures.use feature ‘current_sub’;sub closure { my $init = shift; return sub { state $counter = $init; return if $counter++ > 10; __SUB__->(); }}
  12. 12. 3. CORE Namespace• Namespace for Perl’s core routines• Give access to the original built-in of Perluse v5.16; oruse feature ‘say’; orCORE::say “yes”;
  13. 13. 3. array base• special variable for array base• The array_base feature replace variable $[• $[ affected also string not only arraysuse feature ‘array_base’;$[ = 1;
  14. 14. 3. debugger• Tracing mode (t command) accept number of subroutine for trace• Breakpoints with file names$ b [file]:[line] [condition]$ b lib/MyModule.pm:237 $x > 30
  15. 15. 4. New documentation• perldtrace• perlexperiment• perlootut• perlxstypemap
  16. 16. 5. Performance Improved performance for Unicode properties in regexp local $_ is faster now More? perl5160delta.pod
  17. 17. Used resources• Perl5160delta.pod• www.effectiveperlprogramming.com• Mailing list of p5p
  18. 18. Thank you for attention!paul.vlasov@gmail.com

×