• Share
  • Email
  • Embed
  • Like
  • Save
  • Private Content
Perl 5.12 for Everyday Use
 

Perl 5.12 for Everyday Use

on

  • 1,939 views

 

Statistics

Views

Total Views
1,939
Views on SlideShare
1,898
Embed Views
41

Actions

Likes
1
Downloads
39
Comments
0

1 Embed 41

http://blog.briang.org 41

Accessibility

Categories

Upload Details

Uploaded via as Adobe PDF

Usage Rights

© All Rights Reserved

Report content

Flagged as inappropriate Flag as inappropriate
Flag as inappropriate

Select your reason for flagging this presentation as inappropriate.

Cancel
  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

    Perl 5.12 for Everyday Use Perl 5.12 for Everyday Use Presentation Transcript

    • Perl 5.12 for everyday useSunday, December 5, 2010
    • 5.12 isn’t like 5.10 perl5100deltaSunday, December 5, 2010
    • 5.12 isn’t like 5.10 - after 5.8, we had to wait 5 years for 5.10 perl5100deltaSunday, December 5, 2010
    • 5.12 isn’t like 5.10 - after 5.8, we had to wait 5 years for 5.10 - 5.12 came out 2 years after 5.10 perl5100deltaSunday, December 5, 2010
    • 5.12 is a Nice Change perl5100deltaSunday, December 5, 2010
    • 5.12 is a Nice Change - 5.10 was a huge set of changes perl5100deltaSunday, December 5, 2010
    • 5.12 is a Nice Change - 5.10 was a huge set of changes - 5.12 is a lot smaller perl5100deltaSunday, December 5, 2010
    • 5.12 is a Nice Change - 5.10 was a huge set of changes - 5.12 is a lot smaller - 5.12 is not as compelling as 5.10 perl5100deltaSunday, December 5, 2010
    • 5.12 is a Nice Change - 5.10 was a huge set of changes - 5.12 is a lot smaller - 5.12 is not as compelling as 5.10 - and that’s a good thing perl5100deltaSunday, December 5, 2010
    • 5.12 is a Mixed Bag perl5100deltaSunday, December 5, 2010
    • 5.12 is a Mixed Bag - this talk isn’t just for beginners perl5100deltaSunday, December 5, 2010
    • 5.12 is a Mixed Bag - this talk isn’t just for beginners - some of these changes are at the edges perl5100deltaSunday, December 5, 2010
    • 5.12 is a Mixed Bag - this talk isn’t just for beginners - some of these changes are at the edges - but they’re all practical perl5100deltaSunday, December 5, 2010
    • 5.12 is a Mixed Bag - this talk isn’t just for beginners - some of these changes are at the edges - but they’re all practical - except for the ones that aren’t perl5100deltaSunday, December 5, 2010
    • By the way, 5.14... perl5132deltaSunday, December 5, 2010
    • By the way, 5.14... - is going to be awesome perl5132deltaSunday, December 5, 2010
    • By the way, 5.14... - is going to be awesome - and available in about nine months perl5132deltaSunday, December 5, 2010
    • By the way, 5.14... - is going to be awesome - and available in about nine months - and it’s going to be awesome perl5132deltaSunday, December 5, 2010
    • ...and 5.10 is frozen. perl5101deltaSunday, December 5, 2010
    • ...and 5.10 is frozen. - 5.10 is the last release of the old way perl5101deltaSunday, December 5, 2010
    • ...and 5.10 is frozen. - 5.10 is the last release of the old way - that means it got some features backported perl5101deltaSunday, December 5, 2010
    • ...and 5.10 is frozen. - 5.10 is the last release of the old way - that means it got some features backported - that will never happen again perl5101deltaSunday, December 5, 2010
    • ...and 5.10 is frozen. - 5.10 is the last release of the old way - that means it got some features backported - that will never happen again - I’ll point out 5.12isms that got into 5.10.1 perl5101deltaSunday, December 5, 2010
    • but enough about other versionsSunday, December 5, 2010
    • let’s talk about 5.12Sunday, December 5, 2010
    • First: A Warning featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators - they’re not enabled by default featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.012; featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.012; - read the perldoc featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.012; - read the perldoc I’m a perldoc ref! featureSunday, December 5, 2010
    • First: A Warning - 5.12 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.012; - read the perldoc featureSunday, December 5, 2010
    • $old ~~ $new - the smart match operator changed also in 5.10.1 perlsynSunday, December 5, 2010
    • ~~ - no longer commutative; right side wins - non-overloaded objects can’t be ~~ed - still very complicated (23 behaviors) - you won’t be using this every day perldocSunday, December 5, 2010
    • autodie also in 5.10.1 autodieSunday, December 5, 2010
    • autodie - like Fatal also in 5.10.1 autodieSunday, December 5, 2010
    • autodie - like Fatal - but deadlier also in 5.10.1 autodieSunday, December 5, 2010
    • autodie open my $fh, ‘>‘, $filename; while (<$fh>) { ... } close $fh; autodieSunday, December 5, 2010
    • autodie open my $fh, ‘>‘, $filename or die “couldn’t open $filename: $!”; while (<$fh>) { ... } close $fh or die “couldn’t close $filename: $!”; autodieSunday, December 5, 2010
    • autodie use autodie; open my $fh, ‘<‘, $filename; while (<$fh>) { ... } close $fh; autodieSunday, December 5, 2010
    • autodie use autodie; open my $fh, ‘>‘, $filename; while (<$fh>) { no autodie; rmdir or warn “couldn’t remove $_: $!”; } close $fh; autodieSunday, December 5, 2010
    • autodie problems - autodie doesn’t affect print - you must close filehandles explicitly perldocSunday, December 5, 2010
    • UnicodeSunday, December 5, 2010
    • Perl is Good at Unicode perlunicodeSunday, December 5, 2010
    • Perl 5.12 is Better perlunicodeSunday, December 5, 2010
    • Perl 5.12 is Better - Unicode 5.2 perlunicodeSunday, December 5, 2010
    • Perl 5.12 is Better - Unicode 5.2 - every character property is available perlunicodeSunday, December 5, 2010
    • Perl 5.12 is Better - Unicode 5.2 - every character property is available - X in regex is more sensible perlunicodeSunday, December 5, 2010
    • “The Unicode Bug” perlunicodeSunday, December 5, 2010
    • “The Unicode Bug” - strings aren’t always treated as Unicode perlunicodeSunday, December 5, 2010
    • “The Unicode Bug” - strings aren’t always treated as Unicode - this causes weird bugs that take ages to find perlunicodeSunday, December 5, 2010
    • “The Unicode Bug” - strings aren’t always treated as Unicode - this causes weird bugs that take ages to find - use feature ‘unicode_strings’; perlunicodeSunday, December 5, 2010
    • use feature ‘unicode_strings’; perldocSunday, December 5, 2010
    • use 5.12.0; perldocSunday, December 5, 2010
    • use 5.10.0; perldocSunday, December 5, 2010
    • use 5.10.0; use feature qw( say state switch ); perldocSunday, December 5, 2010
    • use 5.12.0; perldocSunday, December 5, 2010
    • use 5.12.0; use feature qw( say state switch unicode_strings ); perldocSunday, December 5, 2010
    • use 5.12.0; use feature qw( say state switch unicode_strings ); use strict; perldocSunday, December 5, 2010
    • Container ImprovementsSunday, December 5, 2010
    • my %hash = (a => 1, b => 2); while (my ($k, $v) = each %hash) { say “value for $k is $v”; }Sunday, December 5, 2010
    • my %hash = (a => 1, b => 2); while (my ($k, $v) = each %hash) { say “value for $k is $v”; } value for a is 1 value for b is 2Sunday, December 5, 2010
    • Sunday, December 5, 2010
    • my @array = qw(a b);Sunday, December 5, 2010
    • my @array = qw(a b); value for 0 is b value for 1 is aSunday, December 5, 2010
    • my @array = qw(a b); for my $k (0 .. $#array) { say “value for $k is $array[$k]”; } value for 0 is b value for 1 is aSunday, December 5, 2010
    • my @array = qw(a b); while (my ($k, $v) = each @array) { say “value for $k is $v”; } value for 0 is b value for 1 is aSunday, December 5, 2010
    • my @array = qw(a b); for my $k (0 .. $#array) { say “value for $k is $array[$k]”; } my @array = qw(a b); while (my ($k, $v) = each @array) { say “value for $k is $v”; }Sunday, December 5, 2010
    • sub redump { my ($href) = @_; while (my ($k, $v) = each %hash) { say “value for $k is $v”; } } my %hash = (a => 1, b => 2); while (my ($k, $v) = each %hash) { print “== $k ==”; redump(%hash); }Sunday, December 5, 2010
    • my @array = qw(a b); while (my ($k, $v) = each @array) { say “value for $k is $v”; }Sunday, December 5, 2010
    • my @array = qw(a b); while (my ($k, $v) = each @array) { say “value for $k is $v”; do_something(@array); }Sunday, December 5, 2010
    • my @array = qw(a b); while (my ($k, $v) = each @array) { say “value for $k is $v”; }Sunday, December 5, 2010
    • my @array = qw(a b); while (my ($k, $v) = each @array) { my $string = $part_for_maybe_transient->bodyhandle->as_string; my $transient_pos = _match_position($string, $Not_An_Error); last unless defined $transient_pos; my $permanent_pos = _match_position($string, $Really_An_Error); my $orig_msg_pos = _match_position($string, $Returned_Message_Below); last if _position_before($permanent_pos, $orig_msg_pos); if (_position_before($transient_pos, $orig_msg_pos)) { say “value for $k is $v”; last if $message->effective_type eq ‘multipart/report’; last if !$first_part || $first_part->effective_type ne ‘text/plain’; my $string = $first_part->as_string; last if length($string) > 3000; # added return receipt (fix for bug #41870) last if $string !~ /auto.{0,20}reply|return receipt |vacation|(out|away|on holiday).*office/i; $self->log(“looks like an autoreply, ignoring.”); $self->{type} = “vacation autoreply”; $self->{is_bounce} = 0; return $self; } }Sunday, December 5, 2010
    • AVOID each @arraySunday, December 5, 2010
    • local ??Sunday, December 5, 2010
    • use Ancient::Utility qw(stuff); my $result = do { local $Ancient::Utility::WIDTH = 10; stuff( $input ); };Sunday, December 5, 2010
    • my $href = { a => 1, b => 2 }; my $result = do { local $href->{a} = 3; stuff( $href ); };Sunday, December 5, 2010
    • my $href = { a => 1, b => 2 }; my $result = do { delete local $href->{a}; stuff( $href ); };Sunday, December 5, 2010
    • $]Sunday, December 5, 2010
    • $[Sunday, December 5, 2010
    • $[ - first index of array perlvarSunday, December 5, 2010
    • $[ - first index of array - so you can make $array[1] mean first perlvarSunday, December 5, 2010
    • $[ - first index of array - so you can make $array[1] mean first - isn’t that awesome??? perlvarSunday, December 5, 2010
    • $[ - first index of array - so you can make $array[1] mean first - isn’t that awesome??? - yeah, about as awesome as Comic Sans perlvarSunday, December 5, 2010
    • $[ $[ = 1; for (1 .. $#array) { ... } perlvarSunday, December 5, 2010
    • $[ for ($[ .. $#array) { ... } perlvarSunday, December 5, 2010
    • $[ Assigned to $[. Are you some kind of idiot or something? at -e line 123. perlvarSunday, December 5, 2010
    • $[ Use of assignment to $[ is deprecated at -e line 123. perlvarSunday, December 5, 2010
    • More About DeprecationsSunday, December 5, 2010
    • @INCSunday, December 5, 2010
    • @INC: /usr/pkg/lib/perl5/5.8.0/i386-solaris /usr/pkg/lib/perl5/5.8.0 /usr/pkg/lib/perl5/site_perl/5.8.0/i386-solaris /usr/pkg/lib/perl5/site_perl/5.8.0 /usr/pkg/lib/perl5/site_perl /usr/pkg/lib/perl5/vendor_perl/5.8.0/i386-solaris /usr/pkg/lib/perl5/vendor_perl/5.8.0 /usr/pkg/lib/perl5/vendor_perl perlvarSunday, December 5, 2010
    • @INC: /usr/pkg/lib/perl5/5.8.0/i386-solaris /usr/pkg/lib/perl5/5.8.0 /usr/pkg/lib/perl5/site_perl/5.8.0/i386-solaris /usr/pkg/lib/perl5/site_perl/5.8.0 /usr/pkg/lib/perl5/site_perl /usr/pkg/lib/perl5/vendor_perl/5.8.0/i386-solaris /usr/pkg/lib/perl5/vendor_perl/5.8.0 /usr/pkg/lib/perl5/vendor_perl perlvarSunday, December 5, 2010
    • @INC: /usr/pkg/lib/perl5/site_perl/5.8.0/i386-solaris /usr/pkg/lib/perl5/site_perl/5.8.0 /usr/pkg/lib/perl5/site_perl /usr/pkg/lib/perl5/vendor_perl/5.8.0/i386-solaris /usr/pkg/lib/perl5/vendor_perl/5.8.0 /usr/pkg/lib/perl5/vendor_perl /usr/pkg/lib/perl5/5.8.0/i386-solaris /usr/pkg/lib/perl5/5.8.0 perlvarSunday, December 5, 2010
    • now we can remove stuff from the core distributionSunday, December 5, 2010
    • Class::ISA Pod::Plainer ShellSunday, December 5, 2010
    • Class::ISA Pod::Plainer Shell SwitchSunday, December 5, 2010
    • … and …Sunday, December 5, 2010
    • Sunday, December 5, 2010
    • my $x = get_input;Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) {Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) { do_something for 0 .. $x;Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) { do_something for 0 .. $x; } else {Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) { do_something for 0 .. $x; } else { ...Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) { do_something for 0 .. $x; } else { ... }Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) { do_something for 0 .. $x; } else { ... }Sunday, December 5, 2010
    • my $x = get_input; if ( $x >= 0 ) { do_something for 0 .. $x; } else { die “Unimplemented” }Sunday, December 5, 2010
    • sub virtual_method { ... }Sunday, December 5, 2010
    • sub method_I_will_write_later { ... }Sunday, December 5, 2010
    • Unimplemented at Some::Library line 123Sunday, December 5, 2010
    • AVOID ...Sunday, December 5, 2010
    • AVOID ... (except maybe in slides and pseudocode)Sunday, December 5, 2010
    • sub virtual_method { confess ‘...’ } sub method_I_will_write_later { confess ‘...’ }Sunday, December 5, 2010
    • error message improvementsSunday, December 5, 2010
    • perldiagSunday, December 5, 2010
    • perldiagSunday, December 5, 2010
    • perldiagSunday, December 5, 2010
    • perl -MCGI -e’my $q = CGI->new;’ Unrecognized character xE2 in column 12 at -e line 1. perldiagSunday, December 5, 2010
    • perl -MCGI -e’my $q = CGI->new;’ Unrecognized character xE2 in column 12 at -e line 1. perl -MCGI -e’my $q = CGI­−->new;’ Unrecognized character xE2; marked by <-- HERE after y $q = CGI<-- HERE near column 12 at -e line 1. perldiagSunday, December 5, 2010
    • My Favorite 5.10-ism? $str = “Greetings, $name. Your last login was $last. It is now $time.”; Use of uninitialized value $time in concatenation (.) or string at hello.plx line 9. perldiagSunday, December 5, 2010
    • My Favorite 5.12-ism? if (length $input->{new_email}) { $user->update_email(...); } perldiagSunday, December 5, 2010
    • My Favorite 5.12-ism? if (length $input->{new_email}) { $user->update_email(...); } Use of uninitialized value in length at - line 3120. perldiagSunday, December 5, 2010
    • My Favorite 5.12-ism? if (length $input->{new_email}) { $user->update_email(...); } perldiagSunday, December 5, 2010
    • overloadingSunday, December 5, 2010
    • my $object = Object->new; print $object;Sunday, December 5, 2010
    • my $object = Object->new; { no overloading; print $object; }Sunday, December 5, 2010
    • my $filename = get_filename; if (-d $filename) { handle_directory($filename); }Sunday, December 5, 2010
    • package Filename; use overload ‘-X’ => sub { my ($self, $test) = @_; return $self->is_dir if $test eq ‘d’; return $self->cd_able if $test eq ‘x’; ...; };Sunday, December 5, 2010
    • my $file = get_file; if (-d $file) { handle_directory($file); }Sunday, December 5, 2010
    • my $filename = get_file; if (-d $file and -x _) { handle_directory($file); }Sunday, December 5, 2010
    • my $filename = get_filename; if (-d -x $filename) { handle_directory($filename); }Sunday, December 5, 2010
    • AVOID overload -XSunday, December 5, 2010
    • y2038Sunday, December 5, 2010
    • Sunday, December 5, 2010
    • ~$ perl5.10.0 -E ‘say scalar localtime 2**31-1’Sunday, December 5, 2010
    • ~$ perl5.10.0 -E ‘say scalar localtime 2**31-1’ Mon Jan 18 22:14:07 2038Sunday, December 5, 2010
    • ~$ perl5.10.0 -E ‘say scalar localtime 2**31-1’ Mon Jan 18 22:14:07 2038 ~$ perl5.10.0 -E ‘say scalar localtime 2**31’Sunday, December 5, 2010
    • ~$ perl5.10.0 -E ‘say scalar localtime 2**31-1’ Mon Jan 18 22:14:07 2038 ~$ perl5.10.0 -E ‘say scalar localtime 2**31’ Fri Dec 13 15:45:52 1901Sunday, December 5, 2010
    • Sunday, December 5, 2010
    • ~$ perl5.12.0 -E ‘say scalar localtime 2**31-1’Sunday, December 5, 2010
    • ~$ perl5.12.0 -E ‘say scalar localtime 2**31-1’ Mon Jan 18 22:14:07 2038Sunday, December 5, 2010
    • ~$ perl5.12.0 -E ‘say scalar localtime 2**31-1’ Mon Jan 18 22:14:07 2038 ~$ perl5.12.0 -E ‘say scalar localtime 2**31’Sunday, December 5, 2010
    • ~$ perl5.12.0 -E ‘say scalar localtime 2**31-1’ Mon Jan 18 22:14:07 2038 ~$ perl5.12.0 -E ‘say scalar localtime 2**31’ Mon Jan 18 22:14:08 2038Sunday, December 5, 2010
    • some non-everyday changesSunday, December 5, 2010
    • Method Resolution Order A B C D mroSunday, December 5, 2010
    • Method Resolution Order A - 5.8 : D, B, A, C B C D mroSunday, December 5, 2010
    • Method Resolution Order A - 5.8 : D, B, A, C - 5.10: D, B, C, A B C D mroSunday, December 5, 2010
    • Method Resolution Order A - 5.8 : D, B, A, C - 5.10: D, B, C, A B C - 5.12: Anything! D mroSunday, December 5, 2010
    • Method Resolution Order A - 5.8 : D, B, A, C - 5.10: D, B, C, A B C - 5.12: F D MRO::DefineSunday, December 5, 2010
    • use strict; use warnings; package Booster::Gold; our $VERSION = ‘1.00’; ... 1;Sunday, December 5, 2010
    • use 5.12.0; use warnings; package Booster::Gold 1.00; ... 1;Sunday, December 5, 2010
    • use 5.14.0; use warnings; package Booster::Gold 1.00 { ... } 1;Sunday, December 5, 2010
    • http://www.perl.org/get.htmlSunday, December 5, 2010
    • Any questions?Sunday, December 5, 2010