joshywashy has asked for the wisdom of the Perl Monks concerning the following question:
I have an if expression in which I am trying to match multiple strings using the || operator. I would like to reuse my IF statement to search for other sets of strings. What is the proper way to store these sets of strings? I have something like this:
if( /sdfsd/||/abc/||/def/||/hijk/ ) {.....}
I would like to turn it into something like this:
$a = /sdfsd/||/abc/||/def/||/hijk/; $b = /qqqq/||/ff/||/wqeoir/; if ($a) {...}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Storing pattern matches
by ww (Archbishop) on Jan 04, 2014 at 02:23 UTC | |
|
Re: Storing pattern matches
by davido (Cardinal) on Jan 04, 2014 at 02:44 UTC | |
|
Re: Storing pattern matches
by NetWallah (Canon) on Jan 04, 2014 at 01:17 UTC | |
|
Re: Storing pattern matches
by basiliscos (Pilgrim) on Jan 04, 2014 at 10:33 UTC | |
|
Re: Storing pattern matches
by Anonymous Monk on Jan 04, 2014 at 03:38 UTC |