Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Re: Returning regexp pattern that was used to match

by crabbdean (Pilgrim)
on May 03, 2004 at 15:18 UTC ( #350045=note: print w/ replies, xml ) Need Help??


in reply to Re: Returning regexp pattern that was used to match
in thread Returning regexp pattern that was used to match

Woah, what is that syntax!! ++ for the mystery factor alone! I've never seen that before. I couldn't find it in my manuals. Please explain?!


Dean
The Funkster of Mirth
Programming these days takes more than a lone avenger with a compiler. - sam
RFC1149: A Standard for the Transmission of IP Datagrams on Avian Carriers


Comment on Re: Re: Returning regexp pattern that was used to match
Re: Re: Re: Returning regexp pattern that was used to match
by Ven'Tatsu (Deacon) on May 03, 2004 at 15:53 UTC
    (?{ CODE }) will execute any perl code when the regex engine tries to match it. So for example:
    my $string = "Bar"; $sting =~ /Foo(?{ print "Found a Foo\n" })|Bar(?{ print "Found a Bar\n +" })|Baz(?{ print "Found a Baz\n" })/;
    Should print out 'Found a Bar'.

    It's documented in the perlre man page under 'Extended Patterns'.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://350045]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2015-07-05 18:05 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls