in reply to Reseting pos()

pos($titles) = 0;

For example,

my $titles = 'abcde'; for (1..2) { pos($titles) = 0; for (1..3) { $titles =~ /./g or die; print(substr($titles, pos($titles)-1, 1), "\n"); } }

prints

a b c a b c

You should probably be using index, though.

Update: Added example.

Replies are listed 'Best First'.
Re^2: Reseting pos()
by EvanCarroll (Chaplain) on May 02, 2008 at 20:31 UTC