Orchid Fairy (兰花仙子) wrote: > Hi, > > # perl -le '$_="aXXXb"; print "one word is $1" while(/(X*)/g);' > one word is > one word is XXX > one word is > one word is > > > what are the three empty values in the output?
Adding pos() (see `perldoc -f pos`) shows what is happening: $ perl -le '$_="aXXXb"; print "one word is $1 at ", pos while(/(X*)/g);' one word is at 0 one word is XXX at 4 one word is at 4 one word is at 5 $ perl -le '$_="aaXXXbb"; print "one word is $1 at ", pos while(/(X*)/g);' one word is at 0 one word is at 1 one word is XXX at 5 one word is at 5 one word is at 6 one word is at 7 It seems to be picking up an extra empty string after a non-zero length match. Also: $ perl -le '$_="aXXXb"; @captured = $_ =~ m{ (X*) }gmsx;print "captured: <", join( ">, <",@captured), ">"' captured: <>, <XXX>, <>, <> -- Just my 0.00000002 million dollars worth, Shawn Programming is as much about organization and communication as it is about coding. I like Perl; it's the only language where you can bless your thingy. -- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/