# File: defect1.pl use strict; use warnings; my $str = " xyz"; $str =~ /^(\s*)/g or die; print("match1: pos=", pos($str), "\n"); $str =~ /\G(\s*)/g or die; print("match2: pos=", pos($str), "\n"); $str =~ /\G(\s*)/g or die; print("match3: pos=", pos($str), "\n");