in reply to s/// operator and undef question...
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/; }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: s/// operator and undef question...
by merlyn (Sage) on Dec 13, 2000 at 05:41 UTC |