Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re^2: Simplifying for loop and applying multiple push function

by VSarkiss (Monsignor)
on Dec 14, 2005 at 21:22 UTC ( [id://516768]=note: print w/replies, xml ) Need Help??


in reply to Re: Simplifying for loop and applying multiple push function
in thread Simplifying for loop and applying multiple push function

To my way of thinking, it's simpler to write:

@one = values %hash; @two = keys %hash;
Even though the net result is the same.

Just wanted to show another WTDI.

Update
Whoops, Roy Johnson is right, this is equivalent only in some circumstances.

Replies are listed 'Best First'.
Re^3: Simplifying for loop and applying multiple push function
by Roy Johnson (Monsignor) on Dec 14, 2005 at 21:23 UTC
    That's only the same if @one and @two started out empty.

    Caution: Contents may have been coded under pressure.
      Why does it matter whether @one or @two are empty beforehand? Won't the status of the hash and the arrays be identical regardless?

        How about if @one and @two arn't empty. The other answers don't empty them, this one clears out any previous values, which may or may not be desired.


        ___________
        Eric Hodges $_='y==QAe=e?y==QG@>@?iy==QVq?f?=a@iG?=QQ=Q?9'; s/(.)/ord($1)-50/eigs;tr/6123457/- \/|\\\_\n/;print;

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://516768]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (5)
As of 2024-04-25 10:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found