perl - How can I extract hash values into an array in their insertion order? -


Given a hash in Pearl (any hash), how can I remove values ​​from that hush, in order Which they were added and put them in an array?

Example:

  My% given = (foo = & gt; '10', bar = & gt; '20 ', baz = & gt; 15' );  

I have to get the following results:

  my @givenValues ​​= (10, 20, 15);  

to perldoc perlfaq4 :


Use from CPAN.

  Use Tie: IxHash; My% myhash tie, 'Tie :: Eckhams'; (My $ i = 0; $ i & lt; 20; $ i ++) {$ myhash {$ i} = 2 * $ i; } My @ keys = keys% myhash; # @keys = (0,1,2,3, ...)  

Comments

Popular posts from this blog

Eclipse CDT variable colors in editor -

AJAX doesn't send POST query -

wpf - Custom Message Box Advice -