linuxkid has asked for the wisdom of the Perl Monks concerning the following question:

i use scalars to hold large, complex data structures, and they often contain anonymous hashes, am i able to get the keys in some way?

--linuxkid imrunningoutofideas.co.cc

Replies are listed 'Best First'.
Re: Get keys from anonymous hashes
by kcott (Archbishop) on Mar 07, 2012 at 18:15 UTC

    I'm guessing you mean a data structure that might be something like:

    my $ds = [ { a => 1, b => 2 }, [ qw{ q w e r t y } ], { c => 3, d => 4 }, ];

    The keys of the third element can be found with: keys %{$ds->[2]}

    If I'm not even close here, please provide an example of the data structure and indicate which keys you're trying to retrieve.

    -- Ken

      Thanks, that works.

      --linuxkid imrunningoutofideas.co.cc
Re: Get keys from anonymous hashes
by choroba (Cardinal) on Mar 07, 2012 at 18:03 UTC
    Do you mean
    keys %{ $hashref }
    Or is it more complicated?

      Thanks!

      --linuxkid imrunningoutofideas.co.cc