in reply to Re^4: using s/ to not only substitute but also modify text
in thread using s/ to not only substitute but also modify text

the only difference is that variable being the defaulted $_ while the other is user-defined

Nope, no "user-defined" variables being used by s/// in either snippet.

my $r = "Time to work"; s/work/play/; print $r;

means

my $r = "Time to work"; $_ =~ s/work/play/; print $r;

Since you never assigned anything to $_, you get a warning. Conversely, you never told s/// to work on $r. Doing either will solve the problem.

my $_ = "Time to work"; s/work/play/; print $_;
my $r = "Time to work"; $r =~ s/work/play/; print $r;

Replies are listed 'Best First'.
Re^6: using s/ to not only substitute but also modify text
by Anonymous Monk on Nov 23, 2008 at 03:55 UTC
    Thanks very much again ikegami.