perl 5.14 for pragmatists

207
Perl 5.14 for pragmatists

Upload: ricardo-signes

Post on 29-Nov-2014

4.817 views

Category:

Technology


1 download

DESCRIPTION

 

TRANSCRIPT

Page 1: Perl 5.14 for Pragmatists

Perl 5.14for pragmatists

Page 2: Perl 5.14 for Pragmatists

perlhist

5.14

Page 3: Perl 5.14 for Pragmatists

perlhist

5.14

- after 5.8, we had to wait 5 years for 5.10

Page 4: Perl 5.14 for Pragmatists

perlhist

5.14

- after 5.8, we had to wait 5 years for 5.10

- 5.12 came out 2 years after 5.10

Page 5: Perl 5.14 for Pragmatists

perlhist

5.14

- after 5.8, we had to wait 5 years for 5.10

- 5.12 came out 2 years after 5.10

- 5.14 came out 1 year after 5.12

Page 6: Perl 5.14 for Pragmatists

perlhist

5.14

- after 5.8, we had to wait 5 years for 5.10

- 5.12 came out 2 years after 5.10

- 5.14 came out 1 year after 5.12

- 5.16 will come 1 year from 5.14

Page 7: Perl 5.14 for Pragmatists

perlhist

5.14

Page 8: Perl 5.14 for Pragmatists

perlhist

5.14

- 5.10 was a huge set of changes (too many!)

Page 9: Perl 5.14 for Pragmatists

perlhist

5.14

- 5.10 was a huge set of changes (too many!)

- 5.12 was a lot smaller

Page 10: Perl 5.14 for Pragmatists

perlhist

5.14

- 5.10 was a huge set of changes (too many!)

- 5.12 was a lot smaller

- 5.14 is in between

Page 11: Perl 5.14 for Pragmatists

perlhist

5.14

- 5.10 was a huge set of changes (too many!)

- 5.12 was a lot smaller

- 5.14 is in between

- just right?

Page 12: Perl 5.14 for Pragmatists

perl5140delta

5.14 is a Mixed Bag

Page 13: Perl 5.14 for Pragmatists

perl5140delta

5.14 is a Mixed Bag

- this talk isn’t just for beginners

Page 14: Perl 5.14 for Pragmatists

perl5140delta

5.14 is a Mixed Bag

- this talk isn’t just for beginners

- some of these changes are at the edges

Page 15: Perl 5.14 for Pragmatists

perl5140delta

5.14 is a Mixed Bag

- this talk isn’t just for beginners

- some of these changes are at the edges

- but they’re all practical

Page 16: Perl 5.14 for Pragmatists

perl5140delta

5.14 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

Page 17: Perl 5.14 for Pragmatists

perl5150delta

By the way, 5.16...

Page 18: Perl 5.14 for Pragmatists

perl5150delta

By the way, 5.16...

- ...and beyond are going to be interesting

Page 19: Perl 5.14 for Pragmatists

perl5150delta

By the way, 5.16...

- ...and beyond are going to be interesting

- stick around right here after the break and hear Jesse “Double Pumpking” Vincent talk about it

Page 20: Perl 5.14 for Pragmatists

perlpolicy

...and 5.10 is EOL

Page 21: Perl 5.14 for Pragmatists

perlpolicy

...and 5.10 is EOL

- we accept critical bugfixes for 2 maint tracks

Page 22: Perl 5.14 for Pragmatists

perlpolicy

...and 5.10 is EOL

- we accept critical bugfixes for 2 maint tracks

- that’s now 5.14 and 5.12

Page 23: Perl 5.14 for Pragmatists

perlpolicy

...and 5.10 is EOL

- we accept critical bugfixes for 2 maint tracks

- that’s now 5.14 and 5.12

- we do security fixes for releases in last 3 years

Page 24: Perl 5.14 for Pragmatists

perlpolicy

...and 5.10 is EOL

- we accept critical bugfixes for 2 maint tracks

- that’s now 5.14 and 5.12

- we do security fixes for releases in last 3 years

- 5.10 was 2007; it gets no promise of support

Page 25: Perl 5.14 for Pragmatists

perlpolicy

...and 5.10 is EOL

- we accept critical bugfixes for 2 maint tracks

- that’s now 5.14 and 5.12

- we do security fixes for releases in last 3 years

- 5.10 was 2007; it gets no promise of support

- if you’re still on 5.8, you’re in the weeds

Page 26: Perl 5.14 for Pragmatists

but enough about other versions

Page 27: Perl 5.14 for Pragmatists

let’s talk about 5.14

Page 28: Perl 5.14 for Pragmatists

feature

First: A Warning

Page 29: Perl 5.14 for Pragmatists

feature

First: A Warning

- 5.14 is backwards compatible

Page 30: Perl 5.14 for Pragmatists

feature

First: A Warning

- 5.14 is backwards compatible

- but has some new behaviors

Page 31: Perl 5.14 for Pragmatists

feature

First: A Warning

- 5.14 is backwards compatible

- but has some new behaviors

- they’re not all enabled by default; feature.pm

Page 32: Perl 5.14 for Pragmatists

feature

First: A Warning

- 5.14 is backwards compatible

- but has some new behaviors

- they’re not all enabled by default; feature.pm

- no new feature.pm features in 5.14!

Page 33: Perl 5.14 for Pragmatists

feature

First: A Warning

- 5.14 is backwards compatible

- but has some new behaviors

- they’re not all enabled by default; feature.pm

- no new feature.pm features in 5.14!

I’m a perldoc ref!

Page 34: Perl 5.14 for Pragmatists

feature

First: A Warning

- 5.14 is backwards compatible

- but has some new behaviors

- they’re not all enabled by default; feature.pm

- no new feature.pm features in 5.14!

Page 35: Perl 5.14 for Pragmatists

perlsyn

Stuff That’s Gone

Page 36: Perl 5.14 for Pragmatists

perlsyn

- modules deprecated in 5.12 are gone in 5.14

Stuff That’s Gone

Page 37: Perl 5.14 for Pragmatists

perlsyn

- modules deprecated in 5.12 are gone in 5.14

- you’ll have to install them from CPAN

Stuff That’s Gone

Page 38: Perl 5.14 for Pragmatists

perlsyn

- modules deprecated in 5.12 are gone in 5.14

- you’ll have to install them from CPAN

- do you care? no, because they are:

Stuff That’s Gone

Page 39: Perl 5.14 for Pragmatists

perlsyn

- modules deprecated in 5.12 are gone in 5.14

- you’ll have to install them from CPAN

- do you care? no, because they are:

- Class::ISA

Stuff That’s Gone

Page 40: Perl 5.14 for Pragmatists

perlsyn

- modules deprecated in 5.12 are gone in 5.14

- you’ll have to install them from CPAN

- do you care? no, because they are:

- Class::ISA

- Pod::Plainer

Stuff That’s Gone

Page 41: Perl 5.14 for Pragmatists

perlsyn

- modules deprecated in 5.12 are gone in 5.14

- you’ll have to install them from CPAN

- do you care? no, because they are:

- Class::ISA

- Pod::Plainer

- Switch

Stuff That’s Gone

Page 42: Perl 5.14 for Pragmatists

Perl4::CoreLibs

Stuff That’s Going

Page 43: Perl 5.14 for Pragmatists

Perl4::CoreLibs

- Devel::DProf

- use Devel::NYTProf instead!

- the Perl 4 core

- bigrat.pl, ftp.pl, etc

- Perl4::CoreLibs

- Shell (again)

Stuff That’s Going

Page 44: Perl 5.14 for Pragmatists

attributes

:=

Page 45: Perl 5.14 for Pragmatists

attributes

:=

sub login : Local { ... }

Page 46: Perl 5.14 for Pragmatists

attributes

:=

sub login : Local { ... }

my $x : Private = 10;

Page 47: Perl 5.14 for Pragmatists

attributes

:=

sub login : Local { ... }

my $x : Private = 10;

my $x := 10;

Page 48: Perl 5.14 for Pragmatists

attributes

:=

sub login : Local { ... }

my $x : Private = 10;

my $x := 10;

Page 49: Perl 5.14 for Pragmatists

perlop

qw()

for my $show qw(Smallville Lost V) { $tivo->cancel_pass( $show );}

Page 50: Perl 5.14 for Pragmatists

perlop

qw()

for my $show (qw(Smallville Lost V)) { $tivo->cancel_pass( $show );}

Page 51: Perl 5.14 for Pragmatists

perl5140delta

That’s it!

Page 52: Perl 5.14 for Pragmatists

perl5140delta

- those are all the things being removed

That’s it!

Page 53: Perl 5.14 for Pragmatists

perl5140delta

- those are all the things being removed

- these are not scary removals

That’s it!

Page 54: Perl 5.14 for Pragmatists

perlsyn

One More Thing!

Page 55: Perl 5.14 for Pragmatists

perlsyn

One More Thing!

$str =~ m/foo/sand bar;

Page 56: Perl 5.14 for Pragmatists

perlsyn

One More Thing!

$str =~ m/foo/sand bar;

$str =~ m/foo/s and bar;

Page 57: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my $hostname = get_hostname;

$hostname =~ s/\..*//;

Page 58: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my $hostname = get_hostname =~ s/\..*//;

Page 59: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

(my $hostname = get_hostname) =~ s/\..*//;

Page 60: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my $hostname = get_hostname =~ s/\..*//r;

Page 61: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my @short_names = map { s/\..*//; } @long_names;

Page 62: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my @short_names = map { s/\..*//; $_ } @long_names;

Page 63: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my @short_names = map { my $x = $_; $x =~ s/\..*//; $s } @long_names;

Page 64: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my @short_names = map { s/\..*//r } @long_names;

Page 65: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

my @short_names = map s/\..*//r, @long_names;

Page 66: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/u

/a

/aa

/l

/d

Page 67: Perl 5.14 for Pragmatists

perllocale

New Regex Modifiers

Page 68: Perl 5.14 for Pragmatists

perllocale

New Regex Modifiers

/l - use locale rules

Page 69: Perl 5.14 for Pragmatists

perllocale

New Regex Modifiers

/l - use locale rules

YOU DON’T WANT THIS

Page 70: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

Page 71: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/u - use Unicode rules

Page 72: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/u - use Unicode rules

\d matches BENGALI DIGIT FOUR

Page 73: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/u - use Unicode rules

\d matches BENGALI DIGIT FOUR

\w matches LATIN SMALL LETTER ETH

Page 74: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/u - use Unicode rules

\d matches BENGALI DIGIT FOUR

\w matches LATIN SMALL LETTER ETH

“\N{LATIN SMALL LIGATURE FF}” =~ /ff/ui

Page 75: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/a - Unicode, but ASCII rules for classes

\d rejects BENGALI DIGIT FOUR

\w rejects LATIN SMALL LETTER ETH

“\N{LATIN SMALL LIGATURE FF}” =~ /ff/ai

Page 76: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/aa - Unicode, ASCII won’t match non-ASCII

\d rejects BENGALI DIGIT FOUR

\w rejects LATIN SMALL LETTER ETH

“\N{LATIN SMALL LIGATURE FF}” !~ /ff/aai

Page 77: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/aa - Unicode, ASCII won’t match non-ASCII

\d rejects BENGALI DIGIT FOUR

\w rejects LATIN SMALL LETTER ETH

“\N{LATIN SMALL LIGATURE FF}” !~ /ff/aai

“\N{LATIN SMALL LIGATURE FF}” !~ /\pL/aai

Page 78: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

Page 79: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - default semantics

Page 80: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - default semantics

Use Unicode if it’s seems like it’s

Page 81: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - default semantics

Use Unicode if it’s seems like it’s maybe kinda unicode or the pattern

Page 82: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - default semantics

Use Unicode if it’s seems like it’s maybe kinda unicode or the pattern uses \p or \N{...}

Page 83: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - default semantics

Use Unicode if it’s seems like it’s maybe kinda unicode or the pattern uses \p or \N{...}

Otherwise, on ASCII systems use ASCII

Page 84: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - default semantics

Use Unicode if it’s seems like it’s maybe kinda unicode or the pattern uses \p or \N{...}

Otherwise, on ASCII systems use ASCII

Otherwise, on EBCDIC systems use Latin-1

Page 85: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

/d - duhhhh-derrrrr semantics

Use Unicode if it’s seems like it’s maybe kinda unicode or the pattern uses \p or \N{...}

Otherwise, on ASCII systems use ASCII

Otherwise, on EBCDIC systems use Latin-1

Page 86: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

# To be really ASCII-only:

die “funny un-American characters” if $str =~ /[^\x00-\x7F]/;

$str =~ /...actual pattern.../;

Page 87: Perl 5.14 for Pragmatists

perlunitut

- Learn as much as you can!

- Seriously!

- Decode user input, use /aa, use \p_

- Consider: use re ‘/aa’

- But mostly: learn more.

What should I do??

Page 88: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

Page 89: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

$ perl-5.12.4 -E ‘say qr//’

Page 90: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

$ perl-5.12.4 -E ‘say qr//’(?-xism:)

Page 91: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

$ perl-5.12.4 -E ‘say qr//’(?-xism:)

$ perl-5.14.1 -E ‘say qr//’

Page 92: Perl 5.14 for Pragmatists

perlre

New Regex Modifiers

$ perl-5.12.4 -E ‘say qr//’(?-xism:)

$ perl-5.14.1 -E ‘say qr//’(?^u:)

Page 93: Perl 5.14 for Pragmatists

perlunitut

Perl is really goodat Unicode.

Page 94: Perl 5.14 for Pragmatists

perlunitut

Perl is really goodat Unicode.

Unicode is justthat complex.

Page 95: Perl 5.14 for Pragmatists

perlunitut

- ...well, as long as we’re on the subject...

More Unicode!

Page 96: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 97: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 98: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 99: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 100: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 101: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 102: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 103: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 104: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 105: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 106: Perl 5.14 for Pragmatists

charnames

Unicode 6

Page 107: Perl 5.14 for Pragmatists

perlunitut

- “unicode_strings” feature is improved

- \N{...} understands abbreviations

- ...and you can make your own

- better support for surrogates and non-characters

More Unicode!

Page 108: Perl 5.14 for Pragmatists

Container Improvements

Page 109: Perl 5.14 for Pragmatists

perl5120delta

Stuff From 5.12

Page 110: Perl 5.14 for Pragmatists

perl5120delta

- local works more better

Stuff From 5.12

Page 111: Perl 5.14 for Pragmatists

perl5120delta

- local works more better

- assigning to $[ gets a warning

Stuff From 5.12

Page 112: Perl 5.14 for Pragmatists

perl5120delta

- local works more better

- assigning to $[ gets a warning

- each works on arrays

Stuff From 5.12

Page 113: Perl 5.14 for Pragmatists

perl5140delta

That Stuff in 5.14

Page 114: Perl 5.14 for Pragmatists

perl5140delta

- local works even more betterer

That Stuff in 5.14

Page 115: Perl 5.14 for Pragmatists

perl5140delta

- local works even more betterer

- assigning to ($[) gets a warning

That Stuff in 5.14

Page 116: Perl 5.14 for Pragmatists

perl5140delta

- local works even more betterer

- assigning to ($[) gets a warning

- each works on arrayrefs

That Stuff in 5.14

Page 117: Perl 5.14 for Pragmatists

perlfunc

each on arrayrefsmy @array = qw( foo bar baz ) ;

while (my ($k, $v) = each @array) { say “$k: $v”;}

Page 118: Perl 5.14 for Pragmatists

perlfunc

each on arrayrefsmy @array = qw( foo bar baz ) ;

while (my ($k, $v) = each @array) { say “$k: $v”;}

0: foo1: bar2: baz

Page 119: Perl 5.14 for Pragmatists

perlfunc

each on arrayrefsmy $array = [ qw( foo bar baz ) ];

while (my ($k, $v) = each $array) { say “$k: $v”;}

0: foo1: bar2: baz

Page 120: Perl 5.14 for Pragmatists

perlfunc

each on arrayrefs

Page 121: Perl 5.14 for Pragmatists

perlfunc

each on arrayrefs

my ($x, $y) = each @{ $h->{foo}[1] }

Page 122: Perl 5.14 for Pragmatists

perlfunc

each on arrayrefs

my ($x, $y) = each @{ $h->{foo}[1] }

my ($x, $y) = each $h->{foo}[1]

Page 123: Perl 5.14 for Pragmatists

AVOIDeach @array

Page 124: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

Page 125: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayref

Page 126: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayref

Page 127: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayref

Page 128: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayref

Page 129: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

Page 130: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayref

Page 131: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayrefvalues $arrayref

Page 132: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayrefvalues $arrayrefeach $arrayref

Page 133: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayrefvalues $arrayrefeach $arrayref

keys $hashref

Page 134: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayrefvalues $arrayrefeach $arrayref

keys $hashrefvalues $hashref

Page 135: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayrefvalues $arrayrefeach $arrayref

keys $hashrefvalues $hashrefeach $hashref

Page 136: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

push $arrayrefpop $arrayrefshift $arrayrefunshift $arrayrefsplice $arrayref

keys $arrayrefvalues $arrayrefeach $arrayref

keys $hashrefvalues $hashrefeach $hashrefEXPERIMENTAL

Page 137: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

Page 138: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) {

Page 139: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_;

Page 140: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_; # do stuff

Page 141: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_; # do stuff}

Page 142: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_; # do stuff}

demo( @array, $n );

Page 143: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_; # do stuff}

demo( @array, $n );demo(\@array, $n );

Page 144: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_; # do stuff}

demo( @array, $n );demo(\@array, $n );demo( %hash, $n );

Page 145: Perl 5.14 for Pragmatists

perlfunc

built-ins on references

sub demo (+$) { my ($x, $y) = @_; # do stuff}

demo( @array, $n );demo(\@array, $n );demo( %hash, $n );demo(\%hash, $n );

Page 146: Perl 5.14 for Pragmatists

perlfunc

Package Blocks

package Library::Awesome;our $VERSION = 1.234;

sub foo { ... }

1;

Page 147: Perl 5.14 for Pragmatists

perlfunc

Package Blocks

package Library::Awesome 1.234 {

sub foo { ... }

}

1;

Page 148: Perl 5.14 for Pragmatists

perlfunc

Package Blocks

package Library::Awesome 1.234 {

sub foo { ... }

}

1;

Page 149: Perl 5.14 for Pragmatists

perlfunc

Package Blocks

package Library::Awesome 0.2-1alpha {

sub foo { ... }

}

1;

Page 150: Perl 5.14 for Pragmatists

perlfunc

Package Blocks

package Library::Awesome 1.234;

sub foo { ... }

1;

Page 151: Perl 5.14 for Pragmatists

perlmodlib

Speaking of Packages

Page 152: Perl 5.14 for Pragmatists

perlmodlib

Speaking of Packages

- Perl 5.14 removed a bunch of modules

Page 153: Perl 5.14 for Pragmatists

perlmodlib

Speaking of Packages

- Perl 5.14 removed a bunch of modules

- ...so there was room to add new ones!

Page 154: Perl 5.14 for Pragmatists

HTTP::Tiny

HTTP::Tiny

use 5.14.0;use HTTP::Tiny;

my $http = HTTP::Tiny->new;my $res = $http->get( $url );

print $res->{content} if $res->{success};

Page 155: Perl 5.14 for Pragmatists

JSON::PP

JSON::PP

use JSON::PP;

my $data = decode_json( $json_string );

my $json = encode_json( $data_struct );

Page 156: Perl 5.14 for Pragmatists

JSON::PP

Page 157: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;

Page 158: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;

Page 159: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;

Page 160: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

Page 161: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

Page 162: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;

Page 163: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );

Page 164: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

Page 165: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

Page 166: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

my $tgz = $http->get( $json->{download_url} );

Page 167: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

my $tgz = $http->get( $json->{download_url} );die $tgz->{reason} unless $tgz->{success};

Page 168: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

my $tgz = $http->get( $json->{download_url} );die $tgz->{reason} unless $tgz->{success};

open my $fh, ‘>’, $dist->{archive};

Page 169: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

my $tgz = $http->get( $json->{download_url} );die $tgz->{reason} unless $tgz->{success};

open my $fh, ‘>’, $dist->{archive};

$fh->print( $tgz->{content} );

Page 170: Perl 5.14 for Pragmatists

JSON::PP

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

my $tgz = $http->get( $json->{download_url} );die $tgz->{reason} unless $tgz->{success};

open my $fh, ‘>’, $dist->{archive};

$fh->print( $tgz->{content} );$fh->close;

Page 171: Perl 5.14 for Pragmatists

IO::File

use 5.14.0;use autodie;use HTTP::Tiny;use JSON::PP;

my $moose = ‘http://api.metacpan.org/release/Moose’;

my $http = HTTP::Tiny->new;my $json = $http->get( $moose );die $json->{reason} unless $json->{success};

my $dist = decode_json( $json );

my $tgz = $http->get( $json->{download_url} );die $tgz->{reason} unless $tgz->{success};

open my $fh, ‘>’, $dist->{archive};

$fh->print( $tgz->{content} );$fh->close;

Page 172: Perl 5.14 for Pragmatists

perlopentut

IO::File

open my $fh, ‘<’, $some_filename or die “can’t open fh: $!”;

print {$fh} “Some output.”;

close $fh or die “can’t close fh: $!”;

Page 173: Perl 5.14 for Pragmatists

autodie

IO::Fileuse 5.10.1;use autodie;

open my $fh, ‘>’, $some_filename;

print {$fh} “Some output.”;

close $fh;

Page 174: Perl 5.14 for Pragmatists

IO::File

IO::Fileuse 5.10.1;use autodie;use IO::File;

open my $fh, ‘>’, $some_filename;

$fh->print( “Some output.” );

$fh->close;

Page 175: Perl 5.14 for Pragmatists

IO::File

IO::Fileuse 5.14.0;use autodie;use IO::File;

open my $fh, ‘>’, $some_filename;

$fh->print( “Some output.” );

$fh->close;

Page 176: Perl 5.14 for Pragmatists

IO::File

IO::Fileuse 5.14.0;use autodie;

open my $fh, ‘>’, $some_filename;

$fh->print( “Some output.” );

$fh->close;

Page 177: Perl 5.14 for Pragmatists

IO::File

IO::Fileuse 5.14.0;use autodie;

open my $fh, ‘>’, $some_filename;

$fh->print( “Some output.” );

$fh->close or die “can’t close: $!”;

Page 178: Perl 5.14 for Pragmatists

perlvar

$@

Page 179: Perl 5.14 for Pragmatists

Try::Tiny

$@

Page 180: Perl 5.14 for Pragmatists

Try::Tiny

$@

- Well, actually, you use Try::Tiny, right?

Page 181: Perl 5.14 for Pragmatists

Try::Tiny

$@

- Well, actually, you use Try::Tiny, right?

- But this makes Try::Tiny more reliable, too!

Page 182: Perl 5.14 for Pragmatists

Try::Tiny

$@

- Well, actually, you use Try::Tiny, right?

- But this makes Try::Tiny more reliable, too!

- You see, eval and $@ are totally awful

Page 183: Perl 5.14 for Pragmatists

perlfunc

use 5.12.0;

{ package X; sub DESTROY { eval { } }}

eval { my $x = bless {} => ‘X’; die “DEATH!!”;};

warn “ERROR: $@”;

Page 184: Perl 5.14 for Pragmatists

perlfunc

use 5.12.0;

{ package X; sub DESTROY { eval { } }}

eval { my $x = bless {} => ‘X’; die “DEATH!!”;};

warn “ERROR: $@”;

$ perl5.12.4 test.plERROR:

Page 185: Perl 5.14 for Pragmatists

perlfunc

use 5.14.0;

{ package X; sub DESTROY { eval { } }}

eval { my $x = bless {} => ‘X’; die “DEATH!!”;};

warn “ERROR: $@”;

Page 186: Perl 5.14 for Pragmatists

perlfunc

use 5.14.0;

{ package X; sub DESTROY { eval { } }}

eval { my $x = bless {} => ‘X’; die “DEATH!!”;};

warn “ERROR: $@”;

$ perl5.14.1 test.plERROR: DEATH!!

Page 187: Perl 5.14 for Pragmatists

Socket

IPv6 Support!

Page 188: Perl 5.14 for Pragmatists

Socket

IPv6 Support!

- IPv4 is getting pretty old

Page 189: Perl 5.14 for Pragmatists

Socket

IPv6 Support!

- IPv4 is getting pretty old

- not a big deal

Page 190: Perl 5.14 for Pragmatists

Socket

IPv6 Support!

- IPv4 is getting pretty old

- not a big deal

- won’t run out of addresses until 2011-04-15

Page 191: Perl 5.14 for Pragmatists

Socket

IPv6 Support!

- IPv4 is getting pretty old

- not a big deal

- won’t run out of addresses until 2011-04-15

- …the future!

Page 192: Perl 5.14 for Pragmatists

More Random Stuff

Page 193: Perl 5.14 for Pragmatists

perlsyn

say “I \o{23145} Perl 5.14!”;

Page 194: Perl 5.14 for Pragmatists

perlsyn

say “I \o{23145} Perl 5.14!”;

I ♥ Perl 5.14!

Page 195: Perl 5.14 for Pragmatists

perlsyn

say “I \23145 Perl 5.14!”;

I ?45 Perl 5.14!

Page 196: Perl 5.14 for Pragmatists

perlsyn

say “I \023145 Perl 5.14!”;

I 145 Perl 5.14!

Page 197: Perl 5.14 for Pragmatists

perlre

# Pretend there are 15 captures:qr{ (1) (2) (3) (4) \7 \10 (5) (6) (7) (8) (9) \7 \10 (10) \7 \10}x;

Page 198: Perl 5.14 for Pragmatists

perlre

# Pretend there are 15 captures:qr{ (1) (2) (3) (4) \o{7} \o{10} (5) (6) (7) (8) (9) \o{7} \o{10} (10) \g{7} \g{10}}x;

Page 199: Perl 5.14 for Pragmatists

perlsyn

my @hex = (0x0D, 0x0A);my @bin = (0b1101, 0b1010);

Page 200: Perl 5.14 for Pragmatists

perlsyn

my @hex = (0x0D, 0x0A);my @bin = (0b1101, 0b1010);

my @hex = (0X0D, 0X0A);my @bin = (0B1101, 0B1010);

Page 201: Perl 5.14 for Pragmatists

perlfunc

printf “%hhu\n”, 10;

printf “%tu\n”, 10;

printf “%zu\n”, 10;

Page 202: Perl 5.14 for Pragmatists

perlfunc

printf “%hhu\n”, 10; # char

printf “%tu\n”, 10; # ptrdiff_t

printf “%zu\n”, 10; # size_t

Page 203: Perl 5.14 for Pragmatists

perlfunc

0.0416303447718782

Page 204: Perl 5.14 for Pragmatists

perlfunc

perl -E ‘srand(1); say rand;’

Page 205: Perl 5.14 for Pragmatists

perlfunc

my $seed = srand;

Page 206: Perl 5.14 for Pragmatists

http://www.perl.org/get.html

Page 207: Perl 5.14 for Pragmatists

Any questions?