Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?

Re: Conditional regex

by linuxer (Curate)
on May 08, 2009 at 21:13 UTC ( #762950=note: print w/replies, xml ) Need Help??

in reply to Conditional regex

Although nowadays I'd prefer to use HTML::Parser or something similar, I think you could use a subroutine call in the replacement part (and use the /e modifier).

sub foo { my $bar = shift; if ( $CONDITION ) { #modify $bar if you need to } return $bar; } my $text =~ s{(<img.+?>)}{foo($1)}sige;

update1: changed quantifier to +?

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://762950]
[ambrus]: Corion: schmorp points out https://metacpan. org/pod/release/ KARASIK/Prima-1. 49/pod/Prima/File. pod,
[ambrus]: so there's an IO waiter (Prima::File) and a timer (Prima::Timer) maybe it's possible to write an AnyEvent loop driver over it, a saner one than POE

How do I use this? | Other CB clients
Other Users?
Others romping around the Monastery: (10)
As of 2016-12-07 16:33 GMT
Find Nodes?
    Voting Booth?
    On a regular basis, I'm most likely to spy upon:

    Results (130 votes). Check out past polls.