wow. didn't expect that.Q:\>perl -le "($x = 'foo') =~ /.(.)/g; print $1; $x = 'bar'; print $1" o a
betterworld and i just tried out some other examples, and it seems that the string buffer is not really emptied.
so $1 just outputs the second and third character of the string, and in the first example you see the remains of the string 'fou'$ perl -MData::Dumper -we'$Data::Dumper::Useqq = 1; ($x = "fou") =~ /.(..)/g; print Dumper $1; $x = "b"; print Dumper $1; ' $VAR1 = "ou"; $VAR1 = "\0u"; $ perl -MData::Dumper -we'$Data::Dumper::Useqq = 1; ($x = "fou") =~ /.(..)/g; print Dumper $1; $x = "ba"; print Dumper $1; ' $VAR1 = "ou"; $VAR1 = "a\0";
In reply to Re^2: Things you should need to know before using Perl regexes. (Humour, with a serious point)
by tinita
in thread Things you should need to know before using Perl regexes. (Humour, with a serious point)
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |