Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

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

    Dave.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2019-06-27 08:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Is there a future for codeless software?



    Results (111 votes). Check out past polls.

    Notices?