Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re^4: About List::Util's pure Perl shuffle()

by ikegami (Pope)
on Jul 12, 2007 at 13:29 UTC ( #626233=note: print w/replies, xml ) Need Help??


in reply to Re^3: About List::Util's pure Perl shuffle()
in thread About List::Util's pure Perl shuffle()

It's similar to print($i, $i++, $i);, at least in effect. Perl must place some form of pointer* to $a[$n]'s value on a stack instead of making a new scalar to save speed and memory. The result is that when $a[$n] is changed by the third expression in the list slice, it also changes the value of the second expression.

By explicitly copying the value of $a[$n] into another variable ($x), changes in $a[$n] no longer affect the result of the slice.

* — An alias? A pointer to the SV?

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://626233]
help
Chatterbox?
[LanX]: shmem: but only because it is taught in school
LanX remembers one curriculum about benny and the punishment whe we didn't laugh ...hill
LanX horror
[Discipulus]: in case of doubt freedom

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (10)
As of 2017-04-27 20:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I'm a fool:











    Results (513 votes). Check out past polls.