in reply to Re^4: Using eval to s/// with a pattern supplied on the command-line
in thread Using eval to s/// with a pattern supplied on the command-line

holli,
But as I said, $_ isn't a copy it is an alias. If you were to do the following:
my @word = qw(one two three four five); for ( @word ) { $_ = uc( $_ ); } print "$_\n" for @word;
You find the underlying array being modified. If the thing being looped over can't be modified you can't change the looping variable. You need to make an explicit copy if you want to do that.

Cheers - L~R

  • Comment on Re^5: Using eval to s/// with a pattern supplied on the command-line
  • Download Code