welle has asked for the wisdom of the Perl Monks concerning the following question:
Dear Monks
I have a long text stored in a variable $text (the problem is, the text must remain in this simple variable). I search with a Regexp in this variable through a while loop
while ( $text =~ /$query/gi ) { do_something(); }
What I'd like to do is to add another condition: **if $text =~ /$query_modified/gi {do_something_different();}**
Why: the sub do_something must process some information depending on the presence of $query_modified in the variable $text. As these conditions may vary across $text, I need to run the two conditions in a way different as the next one proposed which is not good for me as I need to process the two conditions at the same time.
while ( $text =~ /$query/gi ) { do_something(); } while ( $text =~ /$query_modified/gi ) { do_something_different(); }
Is there a way to perform this?
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: While two conditions
by BrowserUk (Patriarch) on May 01, 2012 at 02:21 UTC | |
by GotToBTru (Prior) on May 01, 2012 at 14:24 UTC | |
Re: While two conditions
by GrandFather (Saint) on May 01, 2012 at 00:47 UTC | |
by welle (Beadle) on May 01, 2012 at 08:56 UTC | |
by GrandFather (Saint) on May 01, 2012 at 11:11 UTC | |
by welle (Beadle) on May 01, 2012 at 14:10 UTC | |
by GrandFather (Saint) on May 01, 2012 at 20:56 UTC | |
| |
Re: While two conditions
by Anonymous Monk on May 01, 2012 at 09:22 UTC | |
by welle (Beadle) on May 01, 2012 at 14:17 UTC | |
by Anonymous Monk on May 02, 2012 at 06:40 UTC |
Back to
Seekers of Perl Wisdom