On 2/26/09 Thu  Feb 26, 2009  6:24 AM, "Irfan Sayed"
<irfan_sayed2...@yahoo.com> scribbled:

> Hi All,
>  
> I have sorted one array in ascending order. Now i want to store that sorted
> output (key/value pair ) in new hash. How can i do that.

By design, hashes do not have an order. Key/value pairs are stored randomly
in the hash's internal structure. This is done for efficient lookup.

There is a way to keep hash keys in a certain order (see 'perldoc -q
sorted'), but I wouldn't recommend it until you know what you are doing.

What are the key/value pairs you wish to store in a hash? You only mention a
sorted array. Are the array members to be used as keys or values in the
hash?

> Secondly, i want to delete the first occurence of key/value pair.

First in what sense? Since hashes do not have an intrinsic order, the
concept of 'first' is generally not meaningful.

Perhaps you can tell us what exactly you are trying to do. It would also
help including some sample code that you think will do what you want.



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to