Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw
 
PerlMonks  

Re: Getting keys or values of a file based hash

by Eily (Monsignor)
on Feb 28, 2020 at 16:55 UTC ( [id://11113552]=note: print w/replies, xml ) Need Help??


in reply to Getiing keys or values of a file based hash

Beside the fact that your code doesn't compile, there is another issue with the while loop, keys resets the iterator so each starts from the first pair each time. Your loop basically means that while you get the first key/value pair, print all the keys; which is an infinite loop.

Fletch is probably right and you probably just got this frankencode while trying different ways to debug, but FYI you should avoid using keys or values inside a while(each) loop.

  • Comment on Re: Getting keys or values of a file based hash

Replies are listed 'Best First'.
Re^2: Getting keys or values of a file based hash
by choroba (Cardinal) on Feb 28, 2020 at 17:18 UTC
    > you should avoid using keys or values inside a while(each) loop.

    It's easier to always avoid each which is the advice I listen to.

    map{substr$_->[0],$_->[1]||0,1}[\*||{},3],[[]],[ref qr-1,-,-1],[{}],[sub{}^*ARGV,3]

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-25 10:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found