Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

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

by Ven'Tatsu (Deacon)
on May 03, 2004 at 15:53 UTC ( #350058=note: print w/replies, xml ) Need Help??


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

(?{ 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://350058]
help
Chatterbox?
[Corion]: Mhmm. Our datawarehouse is named after the department, except that the department changed its name one year ago. Now I guess I'm looking for the moral equivalent of "THE Datawarehouse", where "THE" stands for "Traditional High-valued Expertise" ;)

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2017-07-26 08:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I came, I saw, I ...
























    Results (386 votes). Check out past polls.