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

Re^2: goto HACK

by Anonymous Monk
on Sep 25, 2018 at 09:24 UTC ( #1222954=note: print w/replies, xml ) Need Help??

in reply to Re: goto HACK
in thread goto HACK

Note that $time++ modifies the element of @times, since 'for' makes $time an alias of each element.

That's kinda creepy! I assumed declaring the var was making a copy of the element that wouldn't change the array. I can't believe I never noticed that... and the same with hash values, but not keys?

Replies are listed 'Best First'.
Re^3: goto HACK
by dave_the_m (Monsignor) on Sep 25, 2018 at 11:53 UTC
    Yes, the keys function returns temporary copies of the keys while values returns the actual values. So
    $_++ for @a; # modifies each element of @a $_++ for values %hash; # modifies every value of %hash $_++ for keys %hash; # doesn't do anything useful


Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (6)
As of 2020-08-12 15:40 GMT
Find Nodes?
    Voting Booth?
    Which rocket would you take to Mars?

    Results (66 votes). Check out past polls.