One way to fix it is to change the for loop to for my $x (...) and add local $_ = $x at the top of the loop.my $op = shift; for (qw/your hand is too cold to hold/) { eval $op; print $@, $_, $/; } __OUTPUT__ Modification of a read-only value attempted at (eval 1) line 1. your Modification of a read-only value attempted at (eval 2) line 1. hand Modification of a read-only value attempted at (eval 3) line 1. is Modification of a read-only value attempted at (eval 4) line 1. too Modification of a read-only value attempted at (eval 5) line 1. cold Modification of a read-only value attempted at (eval 6) line 1. to Modification of a read-only value attempted at (eval 7) line 1. hold
blokhead
In reply to Re: Using eval to s/// with a pattern supplied on the command-line
by blokhead
in thread Using eval to s/// with a pattern supplied on the command-line
by ChrisS
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |