in reply to Re: s/// operator and undef question...
in thread s/// operator and undef question...
My guess is that this returns this is a foo2 of the servise as documented in perlop: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/; }
And so my standard admonition about "don't use $1 except in the context of a conditional" would also apply here, since "most recent success" is contextual.[....] If the pattern evaluates to the empty string, the last successfully executed regular expression is used instead. [....]
-- Randal L. Schwartz, Perl hacker
|
|---|