> Assigning a /gx regexp to a list breaks \G in the following regexp. > > #! /usr/local/bin/perl -w > > $_ = 'a 1 b 2 c 3'; > > print "bug\n"; > ($a, $b) = /^(\w)\s(\d)\s/gx; > print "a=$a b=$b\n"; > ($a, $b) = /\G(\w)\s(\d)/gx; > print "a=$a b=$b\n"; > > print "workaround\n"; > /^(\w)\s(\d)\s/gx; > ($a, $b) = ($1, $2); > print "a=$a b=$b\n"; > ($a, $b) = /\G(\w)\s(\d)/gx; > print "a=$a b=$b\n"; > > Output is > > bug > a=a b=1 > a=a b=1 > workaround > a=a b=1 > a=b b=2 > Sound correct behaviour to me. From perlop: /PATTERN/cgimosx [...] Options are: c Do not reset search position on a failed match when /g is in effect. ----> g Match globally, i.e., find all occurrences. i Do case-insensitive pattern matching. m Treat string as multiple lines. o Compile pattern only once. s Treat string as single line. x Use extended regular expressions. It just appears that your list is too small to hold the rest of the matches. And as the match is finished, \G is resetted. In a scalar context, the 'g' modifier work differently, as it doesn't eat up all matches. Your "workaroud" is the way to do what you want to. Hope it helps, François DésarménienThread Previous | Thread Next