regexmegex has asked for the wisdom of the Perl Monks concerning the following question:
Executed we get:my $ref->{number} = 123; my $arg = shift ( @ARGV ) ; my $regex = qr/(one|two|three|four)/; for (1..10) { if ( ref $ref eq 'HASH' and $arg =~ /$regex/ig ) { print "$arg matches\n"; } else { print "$arg doesn't match\n"; } }
The perl version and OS doesn't matter, it displays the same behavior in Linux & Windows. Perl 5.8 and Perl 5.12. Any ideas will be appreciated.C:\src>perl monks.pl one one matches one doesn't match one matches one doesn't match one matches one doesn't match one matches one doesn't match one matches one doesn't match
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex matches the same pattern alternatively
by AnomalousMonk (Archbishop) on Oct 23, 2011 at 07:37 UTC | |
by regexmegex (Initiate) on Oct 23, 2011 at 09:04 UTC | |
|
Re: Regex matches the same pattern alternatively
by ikegami (Patriarch) on Oct 23, 2011 at 06:52 UTC | |
by regexmegex (Initiate) on Oct 23, 2011 at 06:59 UTC |