And using s///.
Ewww.
print pos($str)-1 while $str =~ /\n/g; print $-[0] while $str =~ /\n/g;
Update: Oops, need to subtract 1 from pos() or use $-[0] as you did in the s/// version.
-sauoq "My two cents aren't worth a dime.";
In reply to Re^2: Finding the positions of a character in a string
by sauoq
in thread Finding the positions of a character in a string
by Limbic~Region
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |