>perl -wMstrict -le "my $string = 'foo bart bare'; ;; if ($string =~ m{bar}g) { print qq{found bar at offset $-[0]}; } print 'string pos is ', defined(pos $string) ? pos $string : 'UNDEF'; ;; if ($string =~ m{foo}g) { print qq{found foo at offset $-[0]}; } print 'string pos is ', defined(pos $string) ? pos $string : 'UNDEF'; ;; if ($string =~ m{bar}g) { print qq{found bar at offset $-[0]}; } print 'string pos is ', defined(pos $string) ? pos $string : 'UNDEF'; " found bar at offset 4 string pos is 7 string pos is UNDEF found bar at offset 4 string pos is 7