in reply to Trying to get index functionality in array context
You can use pos() in combination with m//g ...
while ( $txt =~ /$srch/g ) { push @offset, pos($txt) - 1; }
... or as one-liners ...
push @offset, pos($txt) - 1 while $txt =~ /$srch/g; # while ( $txt =~ /$srch/g ) { push @offset, pos($txt) - 1 }
--k.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: 'Trying! to get! index functionality! in array context!?'
by Anonymous Monk on Jan 28, 2002 at 16:30 UTC |