I'm pretty certain there's one or more things that I'm not taking into account in this example, but you get the general idea ;-)use strict; use warnings; my $string = 'insertreallylongstringwithlotsandlotsoffunkycharactersan +difonefeelsreallyspecialperhapsevenaspacesomewhere"; my $char_to_be_matched = 'X'; my @matches; my $offset = 0; foreach my $char (split(//, $string)) { if($char eq $char_to_be_matched) #alternatively some regex magic { push(@matches, $offset); } $offset++; }
In reply to Re: Producing a list of offsets efficiently
by Forsaken
in thread Producing a list of offsets efficiently
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |