my $str = " xyz" print "$str\n"; $str =~ /^(\s*)/g or die; print("match1: pos=", pos($str), "\n"); print "$str\n"; print "@-\n"; print "@+\n"; $str =~ /\G(\s*)/g or die; print("match2: pos=", pos($str), "\n"); print "$str\n"; print "@-\n"; print "@+\n"; $str =~ /\G(\s*)/g or warn; print("match3: pos=", pos($str), "\n"); print "$str\n"; print "@-\n"; print "@+\n"; #### xyz match1: pos=2 xyz 0 0 2 2 match2: pos=2 xyz 2 2 2 2 Warning: something's wrong at /tmp/Perl-1.pl line 20. Use of uninitialized value in print at /tmp/Perl-1.pl line 21. match3: pos= xyz 2 2 2 2