Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
use strict; use warnings; my $string = '0123efg789efg13'; my @matches; my $x='efg'; #the pattern for (0..10000) { if($string =~ /$x/g){ push @matches, $-[0]; push @matches, $+[0]-1; push @matches,"\n"; } else {last} } print "@matches\n";
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: using foreach with a regex
by moritz (Cardinal) on Dec 05, 2008 at 14:47 UTC | |
by ikegami (Patriarch) on Dec 05, 2008 at 15:50 UTC | |
by JadeNB (Chaplain) on Dec 05, 2008 at 16:36 UTC | |
by JavaFan (Canon) on Dec 05, 2008 at 16:55 UTC |