Perl 5.10 for People Who Aren't Totally Insane
Upcoming SlideShare
Loading in...5
×
 

Perl 5.10 for People Who Aren't Totally Insane

on

  • 83,719 views

All the hype about perl 5.10 can sound a little intimidating. User-level pragmata! Overloadable smartmatching operator! Thread-safe refkey hashes! For Pete's sake, have you heard about lexically ...

All the hype about perl 5.10 can sound a little intimidating. User-level pragmata! Overloadable smartmatching operator! Thread-safe refkey hashes! For Pete's sake, have you heard about lexically scoped pluggable regexp engines?

It's enough to make you think that 5.10's changes are just for the hard-core perl hackers, but it couldn't be further from the truth! The new version of Perl is full of changes that are easy to use and pack lots of useful benefits for doing plain old every day Perl programming.

We'll look at the new features, small and large, and see why you, too, will love 5.10.

Statistics

Views

Total Views
83,719
Views on SlideShare
81,996
Embed Views
1,723

Actions

Likes
40
Downloads
1,806
Comments
12

117 Embeds 1,723

http://www.createwebsite.info 1013
http://perl-howto.de 190
http://www.slideshare.net 154
http://abuzarhamza.posterous.com 101
http://www.perl.it 48
http://techvideos.humourbox.info 32
http://thomas-fahle.blogspot.com 13
http://vioan.blogspot.com 10
http://d.hatena.ne.jp 10
http://translate.googleusercontent.com 7
http://www.fachak.com 5
https://be.dimensional.com 4
http://s3.amazonaws.com 4
http://socialskydivetools.com 3
http://www.realnobile.com 3
http://www.lizr.net 3
http://bioinformed.blogspot.com 3
http://hrmyp.com 3
http://posterous.com 3
http://vioan.blogspot.de 3
http://socialskydivetechniques.com 2
http://fullimmersionvirtualreality.com 2
http://shravankothi.blogspot.com 2
http://www.lmodules.com 2
http://socialskydivetrainer.com 2
http://brentwoodtennesseerealestate.org 2
http://bioprinters.com 2
http://holographicmemorydiscs.com 2
http://www.cars-and-motorcycles-and-trucks.com 2
http://www.filescon.com 2
http://avatarsforsale.com 2
http://personalbrandinglab.com 2
http://crmyp.com 2
http://abuzarhamza.tumblr.com 2
http://3dfolios.com 1
http://www.business1-finance1.com 1
http://www.beauty-fashion-jewelry.com 1
http://www.blogsdirectoryhub.com 1
http://www.rapidshareeasy.com 1
http://webcache.googleusercontent.com 1
https://mercy.blackboard.com 1
http://mubarakworld.blogspot.ca 1
http://www.bidderdirectory.com 1
http://www.newsss.com 1
http://www.traveltravellers.com 1
http://www.game-games-gamer.com 1
http://mubarakworld.blogspot.in 1
http://www.moviecern.com 1
http://www.carocean.co.uk 1
http://www.sport-icx.com 1
More...

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

15 of 12 Post a comment

  • Full Name Full Name Comment goes here.
    Are you sure you want to
    Your message goes here
    Processing…
  • Must see for camel riders
    Are you sure you want to
    Your message goes here
    Processing…
  • I have learned a couple of things from your presentation. Nicely done!

    http://www.riding-mower.org/

    http://www.riding-mower.org/la105-john-deere-lawn-tractor/
    Are you sure you want to
    Your message goes here
    Processing…
  • The slides showing how awful it can be to have to manage your own inside-out objects are not intended to be a robust explanation of how to force yourself to suffer through it, but an overview of the various levels of annoyance that heap up without fieldhashes.<br /><br/>
    Are you sure you want to
    Your message goes here
    Processing…
  • Errata: (?)

    Slide 88:
    =======
    Unless you meant to leave $id as an unused variable to resolve in later slides, I'd suggest this change....

    s( $site{$self} )
    ( $site{$id} )gx

    Slide 89:
    =======
    Ditto

    Also, make these changes
    $new should be $new_id
    $old should be $old_id<br /><br/>
    Are you sure you want to
    Your message goes here
    Processing…
  • Perl 5.10 has been released!
    http://search.cpan.org/~rgarcia/perl-5.10.0/<br /><br/>
    Are you sure you want to
    Your message goes here
    Processing…
Post Comment
Edit your comment

Perl 5.10 for People Who Aren't Totally Insane Perl 5.10 for People Who Aren't Totally Insane Presentation Transcript

  • Perl 5.10 for people who are not insane
  • Perl 5.10 for people who are not totally insane
  • 5.10 isn’t like 5.8.x perl5100delta
  • 5.10 isn’t like 5.8.x - features only get added in new 5.x releases perl5100delta
  • 5.10 isn’t like 5.8.x - features only get added in new 5.x releases - it’s been 5 years since the last release (5.8) perl5100delta
  • 5.10 is Way Cool perl51000delta
  • 5.10 is Way Cool - no significant new features in Perl since 2002 perl51000delta
  • 5.10 is Way Cool - no significant new features in Perl since 2002 - remember how bad you wanted to see Star Wars: Episode 1? perl51000delta
  • 5.10 is Way Cool - no significant new features in Perl since 2002 - remember how bad you wanted to see Star Wars: Episode 1? - that’s how excited you should be for 5.10 perl51000delta
  • 5.10 is Way Cool - no significant new features in Perl since 2002 - remember how bad you wanted to see Star Wars: Episode 1? - that’s how excited you should be for 5.10 - but it won’t suck (no POD race scene) perl51000delta
  • Lexicascopasmartwhat? perl51000delta
  • Lexicascopasmartwhat? - lexically scoped user pragmata! perl51000delta
  • Lexicascopasmartwhat? - lexically scoped user pragmata! - pluggable regex compilation engines! perl51000delta
  • Lexicascopasmartwhat? - lexically scoped user pragmata! - pluggable regex compilation engines! - trie-based non-recursive pattern matching! perl51000delta
  • Lexicascopasmartwhat? - lexically scoped user pragmata! - pluggable regex compilation engines! - trie-based non-recursive pattern matching! - thread-safe weak refkey hashes! perl51000delta
  • Yes, You Care perl51000delta
  • Yes, You Care - Not everything in 5.10 is esoteric. perl51000delta
  • Yes, You Care - Not everything in 5.10 is esoteric. - Not everything in 5.10 is for gurus. perl51000delta
  • Yes, You Care - Not everything in 5.10 is esoteric. - Not everything in 5.10 is for gurus. - Not everything in 5.10 is for C programmers. perl51000delta
  • Yes, You Care - Not everything in 5.10 is esoteric. - Not everything in 5.10 is for gurus. - Not everything in 5.10 is for C programmers. - Not everything in 5.10 is super advanced. perl51000delta
  • First: A Warning feature
  • First: A Warning - 5.10 is backwards compatible feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators - they’re not enabled by default feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.010; feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.010; - read the perldoc feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.010; - read the perldoc I’m a perldoc ref! feature
  • First: A Warning - 5.10 is backwards compatible - but adds new keywords and operators - they’re not enabled by default - use feature ‘mtfnpy’; - use 5.010; - read the perldoc feature
  • say what
  • say $what - new built-in, say - it’s like print - but it adds a newline for you perlfunc
  • say $what perlfunc
  • say $what print “Hello, world!n”; perlfunc
  • say $what print “Hello, world!n”; print “$messagen”; perlfunc
  • say $what print “Hello, world!n”; print “$messagen”; print “$_n” for @lines; perlfunc
  • say $what print “Hello, world!n”; say “Hello, world!”; print “$messagen”; print “$_n” for @lines; perlfunc
  • say $what print “Hello, world!n”; say “Hello, world!”; print “$messagen”; say $message; print “$_n” for @lines; perlfunc
  • say $what print “Hello, world!n”; say “Hello, world!”; print “$messagen”; say $message; print “$_n” for @lines; say for @lines; perlfunc
  • truth and definedness
  • truth and definedness perlop
  • truth and definedness sub record_sale { perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; $amount ||= $product->cost; perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; $amount ||= $product->cost; ... perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; $amount ||= $product->cost; ... } perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; $amount = defined $amount ? $amount : $product->cost; ... } perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; $amount ||= $product->cost; ... } perlop
  • truth and definedness sub record_sale { my ($product, $amount) = @_; $amount ||= $product->cost; ... } perlop
  • the new OR operator sub record_sale { my ($product, $amount) = @_; $amount //= $product->cost; ... } perlop
  • the new OR operator $setting = defined $given ? $given : $default; perlop
  • the new OR operator $setting = $given; unless (defined $setting) { $setting = $default; } perlop
  • the new OR operator $setting = $given || $default; perlop
  • the new OR operator $setting = $given // $default; perlop
  • keeping state
  • State Variables $lines_left = 100; sub read_line { die “trial period expired” unless $lines_left-- > 0; ... } perlsub
  • State Variables my $lines_left = 100; sub read_line { die “trial period expired” unless $lines_left-- > 0; ... } perlsub
  • State Variables { my $lines_left = 100; sub read_line { die “trial period expired” unless $lines_left-- > 0; ... } } perlsub
  • State Variables package Trial::Period; sub new { my ($class, $arg) = @_; my $guts = { lines_left => $arg->{lines}, error_msg => $arg->{error}, }; return bless $guts => $class; } my $LINES = 100; my $ERROR = “sorry, trial period over”; sub consume_line { my $TRIAL = Trial::Period->new({ my ($self) = @_; lines => $LINES, $self->{lines_left}--; error => $ERROR, } }); sub lines_left { sub read_line { my ($self) = @_; $TRIAL->assert_lines_left; return $self->{lines_left}; ... } } sub assert_lines_left { my ($self) = @_; unless ($self->lines_left) { die $self->{error_msg}; } } 1; perlsub
  • State Variables { my $lines_left = 100; sub read_line { die “trial period expired” unless $lines_left-- > 0; ... } } perlsub
  • State Variables sub read_line { state $lines_left = 100; die “trial period expired” unless $lines_left-- > 0; ... } perlsub
  • -x stacking
  • Stackable File Tests if ( -f $file and -w $file and -z $file ) { unlink $file; } perlfunc
  • Stackable File Tests if ( -f $file and -w _ and -z _ ) { unlink $file; } perlfunc
  • Stackable File Tests if (-f -w -z $file) { unlink $file; } perlfunc
  • smart matching
  • Smart Matching perlsyn
  • Smart Matching - a new kind of comparison operator perlsyn
  • Smart Matching - a new kind of comparison operator - its behavior depends on its inputs perlsyn
  • Smart Matching - a new kind of comparison operator - its behavior depends on its inputs - “if these two things match...” perlsyn
  • Smart Matching - a new kind of comparison operator - its behavior depends on its inputs - “if these two things match...” - hard to tell, easy to show... perlsyn
  • Smart Matching perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } elsif ($foo ~~ $code) { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } elsif ($foo ~~ $code) { ... } elsif ($foo ~~ %hash) { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } elsif ($foo ~~ $code) { ... } elsif ($foo ~~ %hash) { ... } elsif ($foo ~~ qr/re/) { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } elsif ($foo ~~ $code) { ... } elsif ($foo ~~ %hash) { ... } elsif ($foo ~~ qr/re/) { ... } elsif ($foo ~~ $bar) { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } elsif ($foo ~~ $code) { ... } elsif ($foo ~~ %hash) { ... } elsif ($foo ~~ qr/re/) { ... } elsif ($foo ~~ $bar) { ... } else { ... } perlsyn
  • Smart Matching given ($foo) { when (undef) { ... } when (@array) { ... } when ($code) { ... } when (%hash) { ... } when (qr/re/) { ... } when ($bar) { ... } default { ... } } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ @array) { ... } elsif ($foo ~~ $code) { ... } elsif ($foo ~~ %hash) { ... } elsif ($foo ~~ qr/re/) { ... } elsif ($foo ~~ $bar) { ... } else { ... } perlsyn
  • Smart Matching if ($foo ~~ undef) { ... } elsif ($foo ~~ $array) { ... } elsif ($foo ~~ $code) { ... } elsif ($foo ~~ $hash) { ... } elsif ($foo ~~ qr/re/) { ... } elsif ($foo ~~ $bar) { ... } else { ... } perlsyn
  • Smart Matching my $test; perlsyn
  • Smart Matching given ($foo) { when (undef) { ... } when ($aref) { ... } when ($code) { ... } when ($href) { ... } when ($regex) { ... } when ($object) { ... } default { ... } } perlsyn
  • Smart Matching given ($foo) { when ($test_1) { ... } when ($test_2) { ... } when ($test_3) { ... } when ($test_4) { ... } when ($test_5) { ... } when ($test_6) { ... } default { ... } } perlsyn
  • Smart Matching perlsyn
  • Smart Matching @want = @have->where($test) perlsyn
  • Smart Matching @want = @have->where($test) @want = @have->where(sub{ …… }) perlsyn
  • Smart Matching @want = @have->where($test) @want = @have->where(sub{ …… }) @want = @have->where(qr/.../sm) perlsyn
  • Smart Matching @want = @have->where($test) @want = @have->where(sub{ …… }) @want = @have->where(qr/.../sm) @want = @have->where([ 1,2,3 ]) perlsyn
  • Smart Matching perlsyn
  • Smart Matching sub where { perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; } perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; } if (ref $test eq ‘CODE’) { perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; } if (ref $test eq ‘CODE’) { return grep { $test->($_) } @$array; perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; } if (ref $test eq ‘CODE’) { return grep { $test->($_) } @$array; } perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; } if (ref $test eq ‘CODE’) { return grep { $test->($_) } @$array; } die “invalid test” perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; if (ref $test eq ‘ARRAY’) { my %known = map {$_=>1} @$test; return grep { $known{$_} } @$array; } if (ref $test eq ‘Regexp’) { return grep { $_ =~ $test } @$array; } if (ref $test eq ‘CODE’) { return grep { $test->($_) } @$array; } die “invalid test” } perlsyn
  • Smart Matching sub where { my ($array, $test) = @_; grep { $_ ~~ $test } @$array; } perlsyn
  • Smart Matching SmartMatch::Sugar perlsyn
  • Smart Matching SmartMatch::Sugar @want = @have->where( hash ) perlsyn
  • Smart Matching SmartMatch::Sugar @want = @have->where( hash ) @want = @have->where( class ) perlsyn
  • Smart Matching SmartMatch::Sugar @want = @have->where( hash ) @want = @have->where( class ) @want = @have->where(isa(‘Foo’)) perlsyn
  • unknown undefined
  • Better Error Message(s) $str = “Greetings, $name. Your last login was $last. It is now $time.”; perldiag
  • Better Error Message(s) $str = “Greetings, $name. Your last login was $last. It is now $time.”; Use of uninitialized value in concatenation (.) or string at hello.plx line 9. perldiag
  • Better Error Message(s) $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. perldiag
  • inside-out objects
  • Inside-Out Objects Hash::Util::FieldHash
  • Inside-Out Objects - traditional objects are a hashref Hash::Util::FieldHash
  • Inside-Out Objects - traditional objects are a hashref - look up attrs in the obj itself by attr name Hash::Util::FieldHash
  • Inside-Out Objects - traditional objects are a hashref - look up attrs in the obj itself by attr name - inside-out objects are content-free refs Hash::Util::FieldHash
  • Inside-Out Objects - traditional objects are a hashref - look up attrs in the obj itself by attr name - inside-out objects are content-free refs - look up attrs in an external hash by obj id Hash::Util::FieldHash
  • Inside-Out Objects - traditional objects are a hashref - look up attrs in the obj itself by attr name - inside-out objects are content-free refs - look up attrs in an external hash by obj id - there are complications for inside-out objects Hash::Util::FieldHash
  • Inside-Out Objects sub size { my $self = shift; if (@_) { return $self->{size} = shift; } else { return $self->{size}; } } Hash::Util::FieldHash
  • Inside-Out Objects my %size; sub size { my $self = shift; if (@_) { return $size{ $self } = shift; } else { return $size{ $self }; } } Hash::Util::FieldHash
  • Inside-Out Objects my %size; sub size { my $self = shift; my $id = refaddr $self; if (@_) { return $size{ $id } = shift; } else { return $size{ $id }; } } Hash::Util::FieldHash
  • Inside-Out Objects my %size; sub size { my $self = shift; my $id = refaddr $self; if (@_) { return $size{ $id } = shift; } else { return $size{ $id }; } } sub DESTROY { my $id = refaddr $_[0]; delete $size{ $id }; } Hash::Util::FieldHash
  • Inside-Out Objects my %size; sub CLONE { sub size { my $class = shift; my $self = shift; my $id = refaddr $self; my @properties = map { values %$_ } values %PROP_DATA_FOR; if (@_) { return $size{ $id } = shift; for my $old_id ( keys %OBJ ) { } else { return $size{ $id }; my $object = $OBJ{ $old_id }; } my $new_id = refaddr $object; } for my $prop ( @properties ) { sub DESTROY { next unless exists $prop->{ $old }; my $id = refaddr $_[0]; $prop->{ $new } = $prop->{ $old }; delete $size{ $id }; delete $prop->{ $old }; } } weaken ( $OBJ{ $new } = $object ); delete $OBJ{ $old }; } } Hash::Util::FieldHash
  • Inside-Out Objects my %OBJECT_REGISTRY; sub CLONE { my %size; my $class = shift; sub size { my $self = shift; my @properties = map { values %$_ } my $id = refaddr $self; values %PROP_DATA_FOR; $self->register_object; for my $old_id ( keys %OBJECT_REGISTRY ) { if (@_) { return $size{ $self } = shift; my $object = } else { $OBJECT_REGISTRY{ $old_id }; return $size{ $self }; my $new_id = refaddr $object; } } for my $prop ( @properties ) { next unless exists $prop- sub DESTROY { >{ $old_id }; my $id = refaddr $_[0]; $prop->{ $new_id } = $prop- delete $size{ $id }; >{ $old_id }; delete $OBJECT_REGISTRY{ $id }; delete $prop->{ $old_id }; } } sub register_object { weaken ( $OBJECT_REGISTRY{ $new_id } = my ($self) = @_; $object ); my $id = refaddr $self; delete $OBJECT_REGISTRY{ $old_id }; $OBJECT_REGISTRY{ $id } = $self; } } } Hash::Util::FieldHash
  • Field Hashes Hash::Util::FieldHash
  • Field Hashes - they’re just like hashes Hash::Util::FieldHash
  • Field Hashes - they’re just like hashes - objects as keys become object ids Hash::Util::FieldHash
  • Field Hashes - they’re just like hashes - objects as keys become object ids - but get destroyed and cloned Hash::Util::FieldHash
  • Field Hashes my %size; sub size { my $self = shift; if (@_) { return $size{ $self } = shift; } else { return $size{ $self }; } } Hash::Util::FieldHash
  • Field Hashes fieldhash my %size; sub size { my $self = shift; if (@_) { return $size{ $self } = shift; } else { return $size{ $self }; } } Hash::Util::FieldHash
  • Field Hashes { fieldhash my %size; sub size { my $self = shift; if (@_) { return $size{ $self } = shift; } else { return $size{ $self }; } } } Hash::Util::FieldHash
  • Field Hashes sub size { my $self = shift; fieldhash state %size; if (@_) { return $size{ $self } = shift; } else { return $size{ $self }; } } Hash::Util::FieldHash
  • lexical topic
  • (topic is how you say $_)
  • Lexical Topic for (@lines) { chomp; next if /^#/; next unless length; s/a/b/; sanity_check; say; } perlvar
  • Lexical Topic for my $line (@lines) { chomp $line; next if $line ~~ /^#/; next unless length $line; $line =~ s/a/b/; sanity_check($line); say $line; } perlvar
  • Lexical Topic for my $_ (@lines) { chomp; next if /^#/; next unless length; s/a/b/; sanity_check; say; } perlvar
  • Regex
  • named captures
  • Regex: Named Captures perlre
  • Regex: Named Captures - find matches by name, not position perlre
  • Regex: Named Captures - find matches by name, not position - avoid the dreaded$1 perlre
  • Regex: Named Captures - find matches by name, not position - avoid the dreaded $1 - no longer second to Python or .Net! perlre
  • Regex: Named Captures # our hypothetical format section:property = value perlre
  • Regex: Named Captures $line ~~ /(w+):(w+) = (w+)/; $name = $2; $value = $3; perlre
  • Regex: Named Captures $lhs_re = qr/(w+):(w+)/; $rhs_re = qr/(w+)/; $line ~~ /$lhs_re = $rhs_re/; $name = $2; $value = $3; perlre
  • Regex: Named Captures $line ~~ /$lhs_re = $rhs_re/; $name = $2; $value = $3; perlre
  • Regex: Named Captures $line ~~ /$lhs_re = $rhs_re/; $name = $+{ name }; $value = $+{ value }; perlre
  • Regex: Named Captures $lhs_re = qr/(w+):(w+)/; $rhs_re = qr/(w+)/; perlre
  • Regex: Named Captures $lhs_re = qr/(w+):(?<name>w+)/; $rhs_re = qr/(?<value>w+)/; perlre
  • better backrefs
  • Regex: Backreference m{< (w+) > .+ < /1 > }x perlre
  • Regex: Backreference m{< (w+) > .+ < /1 > }x perlre
  • Regex: Backreference 10 perlre
  • Regex: Backreference qr{(d)10} perlre
  • Regex: Backreference qr{ (d) 1 0}x perlre
  • Regex: Backreference m{< (w+) > .+ < /1 > }x perlre
  • Regex: Backreference m{< (w+) > .+ < /g{1} > }x perlre
  • Regex: Backreference 10 perlre
  • Regex: Backreference g{10} perlre
  • Regex: Backreference qr{(d)10} perlre
  • Regex: Backreference qr{(d)g{1}0} perlre
  • Regex: Backreference qr{(d)g{-1}0} perlre
  • Regex: Backreference qr{ (?<digit>d) g{digit} 0 }x perlre
  • Regex: Exit Strategy my $wtf_re = qr{ xffn015()]*(?:[^x80-xff][^x80-xffn015()]*)*))[^x80-xf fn015()]*)*)[040t]*)*(?:(?:[^(040)<>@,;:”.[]000-037x80-x ff]+(?![^(040)<>@,;:”.[]000-037x80-xff])|”[^x80-xffn015 “]*(?:[^x80-xff][^x80-xffn015”]*)*”)[040t]*(?:([^x80- xffn015()]*(?:(?:[^x80-xff]|([^x80-xffn015()]*(?:[^x80 -xff][^x80-xffn015()]*)*))[^x80-xffn015()]*)*)[040t]* )*(?:.[040t]*(?:([^x80-xffn015()]*(?:(?:[^x80-xff]|([^ x80-xffn015()]*(?:[^x80-xff][^x80-xffn015()]*)*))[^ x80-xffn015()]*)*)[040t]*)*(?:[^(040)<>@,;:”.[]000-037x8 0-xff]+(?![^(040)<>@,;:”.[]000-037x80-xff])|”[^x80-xffn 015”]*(?:[^x80-xff][^x80-xffn015”]*)*”)[040t]*(?:([^x 80-xffn015()]*(?:(?:[^x80-xff]|([^x80-xffn015()]*(?:[^ x80-xff][^x80-xffn015()]*)*))[^x80-xffn015()]*)*)[040 t]*)*)*@[040t]*(?:([^x80-xffn015()]*(?:(?:[^x80-xff]|([ ^x80-xffn015()]*(?:[^x80-xff][^x80-xffn015()]*)*))[^ x80-xffn015()]*)*)[040t]*)*(?:[^(040)<>@,;:”.[]000-037 x80-xff]+(?![^(040)<>@,;:”.[]000-037x80-xff])|[(?:[^x80- xffn015[]]|[^x80-xff])*])[040t]*(?:([^x80-xffn015() ]*(?:(?:[^x80-xff]|([^x80-xffn015()]*(?:[^x80-xff][^ x80-xffn015()]*)*))[^x80-xffn015()]*)*)[040t]*)*(?:.[04 }; wtf
  • Regex: Backreference if ($str =~ $wtf_re) { ... } perlop
  • Regex: Backreference if ($str ~~ $wtf_re) { ... } perlop
  • lexically scoped alternate trie-based reentrant user- defined regex pragmata
  • flexible regex
  • Alternate Regex Engines perlreapi
  • Alternate Regex Engines - lets you change how regex work perlreapi
  • Alternate Regex Engines - lets you change how regex work - but not how you use them ( , =~ s///, etc) perlreapi
  • Alternate Regex Engines re::engine::POSIX
  • Alternate Regex Engines egrep -r -l PATTERN DIR re::engine::POSIX
  • Alternate Regex Engines my $regex = qr{ ... }; my @files = $find->file->in( $root ); say for grep { slurp ~~ $re } @files; re::engine::POSIX
  • Alternate Regex Engines re::engine::POSIX
  • Alternate Regex Engines egrep -r -l ‘.+?’ DIR re::engine::POSIX
  • Alternate Regex Engines my $regex = qr{ ... }; my @files = $find->file->in( $root ); say for grep { slurp ~~ $re } @files; re::engine::POSIX
  • Alternate Regex Engines use re::engine::POSIX; my $regex = qr{ ... }; my @files = $find->file->in( $root ); say for grep { slurp ~~ $re } @files; re::engine::POSIX
  • Alternate Regex Engines use re::engine::POSIX; my $regex = qr{ ... }x; my @files = $find->file->in( $root ); say for grep { slurp ~~ $re } @files; re::engine::POSIX
  • http://www.perl.org/get.html
  • Any questions?