Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: Method call to tied hash leads to file read error

by broquaint (Abbot)
on May 28, 2003 at 16:38 UTC ( [id://261363]=note: print w/replies, xml ) Need Help??


in reply to Method call to tied hash leads to file read error

It's because in the second instance you're looping over a constant value in the for and the trying to assign that in my_method e.g
sub readstuff { return while <> } print readstuff for 'a constant value'; __output__ Modification of a read-only value attempted at - line 1.
Where the while really compiles as return while defined($_ = <>). As has been mentioned before in IlyaM's while(<>) { ... } considered harmful, be careful when implicitly using $_ in subroutines and methods.
HTH

_________
broquaint

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://261363]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (3)
As of 2024-04-25 06:48 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found