Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^3: How do you find keys of a Blessed Hash?

by roboticus (Chancellor)
on Oct 07, 2012 at 16:56 UTC ( #997692=note: print w/ replies, xml ) Need Help??


in reply to Re^2: How do you find keys of a Blessed Hash?
in thread How do you find keys of a Blessed Hash?

perl-diddler:

Assuming Corion located the problem for you, then you need only dereference the hash yourself, rather than relying on keys to do it for you:

$ cat test.pl #!/usr/bin/perl *STDERR = *STDOUT; $|=1; my $hr = bless {a=>1, b=>2}, "food"; print "Manual deref: ", join(", ", keys %$hr), "\n"; print "Auto deref: ", join(", ", keys $hr), "\n"; $ perl test.pl Manual deref: a, b Type of argument to keys on reference must be unblessed hashref or arr +ayref at test.pl line 8.

Update: Fixed formatting.

...roboticus

When your only tool is a hammer, all problems look like your thumb.


Comment on Re^3: How do you find keys of a Blessed Hash?
Download Code
Replies are listed 'Best First'.
Re^4: How do you find keys of a Blessed Hash?
by perl-diddler (Hermit) on Oct 07, 2012 at 19:53 UTC
    That's actually the problem -- I didn't go run off and try things... Got caught up in something else, as the explanation I got didn't make immediate sense, so... that's when I usually go do something else for a while to let ideas percolate around... that -- and in this case, see what other ideas pop up. I had a ref to a hash---and I left off the % on the front. Gonna have to watch for that one -- the new error message didn't exactly tell me what I'd done the way the old one did. Just have to remember when I see that new error message I should check for typos...Thanks for the followup...

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (18)
As of 2015-07-31 14:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (278 votes), past polls