Re: perl 'read only' situation -- bizarre!
On Mon, 6 Jan 2003, will trillich wrote:
> i noticed my HTML::Mason code, after upgrading from potato to
> woody, started balking at a simple line of code:
>
> my @c = map {s/(.)/$1$1/g; $_} qw(fc0 066 ffc 600 cff 090 ccc 666 fc9 633 cff 096 c9c 090);
>
> now, under potato, there was no problem. with woody, i've got
>
> "Modification of a read-only value attempted"
It's because $_ is an alias to the current element in your list, which is
a constant.
Notice:
$ perl -le '$x = 3;my @c = map {$_=6; $_} ($a); print $a'
6
See, $_ is an alias.
--
Bill Moseley moseley@hank.org
Reply to: