Convert hash values to list

Discussion in 'Perl Misc' started by Shea Martin, Jul 26, 2005.

  1. Shea Martin

    Shea Martin Guest

    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
     
    Shea Martin, Jul 26, 2005
    #1
    1. Advertising

  2. Shea Martin

    Shea Martin Guest

    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
     
    Shea Martin, Jul 26, 2005
    #2
    1. Advertising

  3. Shea Martin

    Paul Lalli Guest

    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
     
    Paul Lalli, Jul 27, 2005
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Klaus Neuner
    Replies:
    7
    Views:
    498
    Klaus Neuner
    Jul 26, 2004
  2. rp
    Replies:
    1
    Views:
    534
    red floyd
    Nov 10, 2011
  3. Alex Fenton

    Hash#values and Hash#keys order

    Alex Fenton, Apr 7, 2006, in forum: Ruby
    Replies:
    1
    Views:
    141
    George Ogata
    Apr 15, 2006
  4. Srijayanth Sridhar
    Replies:
    19
    Views:
    624
    David A. Black
    Jul 2, 2008
  5. dt

    convert string to hash of hash?

    dt, Mar 1, 2007, in forum: Perl Misc
    Replies:
    1
    Views:
    468
    ~greg
    Mar 2, 2007
Loading...

Share This Page