Upload
pavel-vlasov
View
23.050
Download
0
Embed Size (px)
DESCRIPTION
Perl 5.16 new features, YAPC::Russia «May Perl + Perl Mova» Kiev, 12–13 May 2012
Citation preview
Perl 5.16 new features
Pavel Vlasov, 2012
Perl Mova Kiev, Ukraine
Content
1.Perl 5.16 coming
2.Unicode features
3.Other features
4.New documentation
5.Performance
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)
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 - ?????
2. Unicode features
• fc (fold case)
• quotameta
• unicode_eval
• evalbytes
2. Fold case
• Compare strings non-unicode
uc($string1) eq = uc($string2)
$string1 = ‘A’; $string2 = ‘a’;
uc(‘A’) = A uc(‘a) =A
Result: OK
$string1 = ‘ß’;
uc(‘ß’) = ‘SS’
It’s NOT OK
2. Fold case
• Compare strings in unicode
use feature ‘fc’;
fc($unicode1) eq fc($unicode2)
• Use casefolding
• inside a double-quoting string - "\F$variable"
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$substr\E}{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};
2. unicode_eval, evalbytes
unicode_eval default feature of Perl 5.16
eval – evaluate string of characters
evalbytes – die if the string contains any characters outside the 8-bit range
3. Other features
• current sub __SUB__
• CORE namespace
• array base
• debugger
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__->();
}
}
3. CORE Namespace
• Namespace for Perl’s core routines
• Give access to the original built-in of Perl
use v5.16;
or
use feature ‘say’;
or
CORE::say “yes”;
3. array base
• special variable for array base
• The 'array_base' feature replace variable $[
• $[ affected also string not only arrays
use feature ‘array_base’;
$[ = 1;
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
4. New documentation
• perldtrace
• perlexperiment
• perlootut
• perlxstypemap
5. Performance
� Improved performance for Unicode properties in regexp
� local $_ is faster now
� More? perl5160delta.pod
Used resources
• Perl5160delta.pod
• www.effectiveperlprogramming.com
• Mailing list of p5p
Thank you for attention!