On Tue Nov 28 14:04:29 2006, James.Woodworth@ricardo.com wrote: > In a "while" loop, the "backslash-G" does not seem to work for > capturing data of multiple key/value pairs from a common line. > > It was expected that each "<datakey>=<spaces><datavalue>" > would have been captured and printed in this trivial example. > > ################################################################ > # sample program that shows only the first key value pair > # is captured for use. > > # contact info: Jim Woodworth -- james.woodworth@ricardo.com > # thanks. > > use warnings; > use strict; > > while( defined( my $line = <DATA> )) > { > chomp $line; > while( my( $k, $v ) = $line =~ /\G\s*(\S+)=\s+(\S+)/gc ) > { > print "$line\n====k: $k -- v: $v\n"; > } > } When //g is called in list context, it keeps match again and again till the end of the string. Then it returns all the captured text as a list. In scalar context it matches once and remembers its position. You are calling it in list context.