in reply to Why do I need to shuffle an array by reference?
My guess would be that it is common practice to code the shuffle as a sub so that it can be called rather than replicated in-place. Once you place the routine in a sub, it makes sense to pass the array by reference, as to not do so would mean passing the contents of the whole array as a list, which would become prohibitively expensive for large arrays.
For reference, if you are using the shuffle rather than just coding for the sake of learning, there is an implementation of it available in List::Util which comes as standard if you have 5.8.
|
|---|