Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: Apply function "keys" directly to function returning hash

by benn (Priest)
on Aug 25, 2003 at 16:48 UTC ( #286405=note: print w/ replies, xml ) Need Help??


in reply to Apply function "keys" directly to function returning hash

The problem is that you're *not* returning a hash - you're returning a list, which my %hash = func() turns into a hash for you.

One way round this would be to return a hashref instead - something like this...

sub func { return {'a' => 'ah', 'b' => 'be'} }; print keys %{func()}; # a b
Hope this helps,
Ben.


Comment on Re: Apply function "keys" directly to function returning hash
Select or Download Code

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others examining the Monastery: (5)
As of 2015-07-05 07:47 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 (60 votes), past polls