Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight

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?


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 #!/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 Manual deref: a, b Type of argument to keys on reference must be unblessed hashref or arr +ayref at line 8.

Update: Fixed formatting.


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

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?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://997692]
Jar. Jar!...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2018-02-22 11:49 GMT
Find Nodes?
    Voting Booth?
    When it is dark outside I am happiest to see ...

    Results (291 votes). Check out past polls.