in reply to Re: Closure producing 'Modification of read-only value' error
in thread Closure producing 'Modification of read-only value' error
Never local $_ in a subroutine. If you want to use the magic assignment you should do local *_. Of course you have to unpack anything you want from @_ first.
If you get into the habit of doing local $_ inside you subroutines it will seem to work fine - maybe for years. Then one day someone will call one of your subroutines inside a for() loop that is iterating over the values of a tied array or hash. Very odd things will start happening in their program.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^3: Closure producing 'Modification of read-only value' error
by tlm (Prior) on Jun 11, 2005 at 16:39 UTC | |
by nobull (Friar) on Jun 11, 2005 at 19:09 UTC | |
|
Re^3: Closure producing 'Modification of read-only value' error
by kaif (Friar) on Jun 13, 2005 at 02:03 UTC |