L
Larry
I just had my script die with "Attempt to modify read-only value"
(intermittently) on a line that was simply doing:
while (<$inf>) { ... $_ ... }
I did some googling and it seems that this error can happen in cases
where the last time you used $_ it was bound to a variable that you no
longer have the permission to modify. In my particular script, the
problem was ocurring in code that had just done a fork, so it's
probably related to that. I fixed it by changing it to:
while (my $line = <$inF>) { ... $line ... }
My point is that this seems to be a big argument for not using $_.
It's such a commonly used (and convenient) part of the language... it's
disconcerting to find that it's apparently somewhat dangerous.
(intermittently) on a line that was simply doing:
while (<$inf>) { ... $_ ... }
I did some googling and it seems that this error can happen in cases
where the last time you used $_ it was bound to a variable that you no
longer have the permission to modify. In my particular script, the
problem was ocurring in code that had just done a fork, so it's
probably related to that. I fixed it by changing it to:
while (my $line = <$inF>) { ... $line ... }
My point is that this seems to be a big argument for not using $_.
It's such a commonly used (and convenient) part of the language... it's
disconcerting to find that it's apparently somewhat dangerous.