Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Dynamic regex assertions, capturing groups, and parsers: joy and terror

by japhy (Canon)
on Oct 03, 2005 at 14:59 UTC ( #496948=perlmeditation: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # prints 'j'
    "japhy" =~ m{ (.) (?{ print $1 }) }x;
    ...
    # prints nothing (undef, specifically)
    $rx = qr{ (.) (??{ print $1 }) }x;
    "japhy" =~ m{ (??{ $rx }) }x;
    
  2. or download this
    use Data::Dumper;
    $Data::Dumper::Indent = 1;
    ...
      my $alt = pop @r;
      [ @r, { ALT => [ @{ $alt->{ALT} }, $w->{WORD} ] } ];
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlmeditation [id://496948]
Approved by cristian
Front-paged by gmax
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others rifling through the Monastery: (8)
As of 2020-05-28 06:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    If programming languages were movie genres, Perl would be:















    Results (165 votes). Check out past polls.

    Notices?