#! perl -slw use strict; our( $string, @string ); sub parseSome { local $_ = $string; while( my $token = shift @_ ) { m[$token\s+]gc or return; print pos, ' :', substr $_, 0, pos; } } { local $string = 'the quick brown fox jumps over the lazy dog'; $string =~ m[the\s+]gc; print pos( $string ), ' :', substr $string, 0, pos( $string ); parseSome( qw[ quick brown cat ] ); print pos( $string ), ' :', substr $string, 0, pos( $string ); } __END__ C:\test>junk9 4 :the 10 :the quick 16 :the quick brown 4 :the #### local $SIG{__DIE__} = sub{ @{ $self } = @{ $copy } }