in reply to While two conditions
my $text = 'perl monks'; my $query = qr{ (?<M>monk) (?(<M>)(?{do_something_different()})) | (?<P>perl) (?(<P>)(?{do_something()})) }x; while($text =~ /$query/gi){}; sub do_something{ print "found perl\n"; } sub do_something_different{ print "found monk\n"; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: While two conditions
by welle (Beadle) on May 01, 2012 at 14:17 UTC | |
by Anonymous Monk on May 02, 2012 at 06:40 UTC |