Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Perl > Perl Misc > Convert hash values to list

Reply
Thread Tools

Convert hash values to list

 
 
Shea Martin
Guest
Posts: n/a
 
      07-26-2005
Is there a canned method converting a hash to a list of values. i.e.,

@v = values( %myhash );
@k = keys( %myhash );

BTW - I know how to do it with a loop, just wondering if there was a
builtin...

Thanks,

~S
 
Reply With Quote
 
 
 
 
Shea Martin
Guest
Posts: n/a
 
      07-26-2005
Shea Martin wrote:
> Is there a canned method converting a hash to a list of values. i.e.,
>
> @v = values( %myhash );
> @k = keys( %myhash );
>
> BTW - I know how to do it with a loop, just wondering if there was a
> builtin...
>
> Thanks,
>
> ~S


I found the answer. Man looked for about 10 mins on google, with
nothing, usually that means it doesn't exist. I just found the answer on
page 138 of Perl in a Nutshell.

Note to self, RTF!

~S
 
Reply With Quote
 
 
 
 
Paul Lalli
Guest
Posts: n/a
 
      07-27-2005
Shea Martin wrote:
> Shea Martin wrote:
> > Is there a canned method converting a hash to a list of values. i.e.,
> >
> > @v = values( %myhash );
> > @k = keys( %myhash );


I'm confused as to what you're looking for. How does the first
statement above not do what you want?

> >
> > BTW - I know how to do it with a loop, just wondering if there was a
> > builtin...

>
> I found the answer.


Could you possibly post the answer you found (along with a
clarification of the question), to better aide those who might have a
similar question in the future?

> Man looked for about 10 mins on google, with
> nothing, usually that means it doesn't exist. I just found the answer on
> page 138 of Perl in a Nutshell.
>
> Note to self, RTF!


The docs that come with Perl (perldoc) and books specifically written
about Perl (the Camel, Llama, Cookbook, and Nutshell) are generally
more likely to get you answers you're looking for than random webpages
returned by Google.

Paul Lalli

 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
hash of hash of hash of hash in c++ rp C++ 1 11-10-2011 04:45 PM
Hash#select returns an array but Hash#reject returns a hash... Srijayanth Sridhar Ruby 19 07-02-2008 12:49 PM
convert string to hash of hash? dt Perl Misc 1 03-02-2007 04:57 AM
Hash#values and Hash#keys order Alex Fenton Ruby 1 04-15-2006 05:45 AM
convert list of strings to set of regexes; convert list of strings to trie Klaus Neuner Python 7 07-26-2004 07:25 AM



Advertisments