A tidier alternative to my pos() - length($1) is to consult @- .
The difference in indexing is that your code is matching on seperator characters instead of word characters. The end of your first match is the start of my second.push @{$positions{lc($1)}}, $-[1] while $string =~ /([A-Za-z']+)/g;
After Compline,
Zaxo
In reply to Re^3: Newbie Q:How do I compare items within a string?
by Zaxo
in thread Newbie Q:How do I compare items within a string?
by PerlGrrl
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |