in reply to Copy hash's key to an array

Maybe I don't understand, but do you mean these:

# copy keys to array @array = keys %hash; # copy values to array @array = values %hash; # copy key-value pairs to array @array = %hash

Replies are listed 'Best First'.
Re^2: Copy hash's key to an array
by saranrsm (Acolyte) on Oct 21, 2011 at 16:49 UTC

    Deak Monks,

    Thank you very much every one. But is there any other efficient way besides keys and pushing individual keys. I am just being here a bit curious because itz perl and here there's always another way.

      I'm sure there are other ways. You could treat the hash as an array, for instance, and use a loop to pull out all values with even-numbered indexes, starting with zero. But I doubt any other way could be as efficient as the built-in 'keys' function.

      I'm sure Perlmonks could find a few million silly ways to extract the keys from a hash without using the four character buildin called keys.

      But what's the point?