There's a spot of nothing at the very start of the string.my $target = 'this is a test of the servise'; $target =~ s//are/; print "$target\n";
I think you're missing /g at the end of the regex in the loop condition. As for that, my assumption is that there's Deep Magic here, and you shouldn't rely on these results.
Another test:
Maybe a blank regex condition on the left stays with what was previously matched. Dunno if that's an intended feature or not.if ($target =~ /test/) { $target =~ s//quiz/; }
Update: I'm upgrading it to potential bug:
The moral of the story is, don't do a substitution inside a match on the same string.my $target = 'this is a test of the servise'; if ($target =~ /test/) { $target =~ s//test2/; } if ($target =~ /nothing/) { $target = s//null/; } else { $target =~ s//foo/; }
In reply to Re: s/// operator and undef question...
by chromatic
in thread s/// operator and undef question...
by ismail
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |