in reply to Using eval to s/// with a pattern supplied on the command-line
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
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Using eval to s/// with a pattern supplied on the command-line
by ChrisS (Monk) on Mar 16, 2005 at 21:54 UTC | |
|
Re^2: Using eval to s/// with a pattern supplied on the command-line
by holli (Abbot) on Mar 16, 2005 at 21:53 UTC | |
by betterworld (Curate) on Mar 16, 2005 at 22:08 UTC | |
by Limbic~Region (Chancellor) on Mar 16, 2005 at 23:28 UTC | |
by holli (Abbot) on Mar 17, 2005 at 05:52 UTC | |
by Limbic~Region (Chancellor) on Mar 17, 2005 at 13:13 UTC |