And, if you do that a lot, there's this alternative for your consideration:
sub inplace_shuffle { @_[keys @_] = shuffle @_ }
inplace_shuffle (values %foo);
| [reply] [Watch: Dir/Any] [d/l] |
| [reply] [Watch: Dir/Any] [d/l] [select] |
use List::Util qw(shuffle);
use List::MoreUtils qw(zip);
%hash = zip @{[shuffle keys %hash]}, @{[values %hash]};
| [reply] [Watch: Dir/Any] [d/l] |
| [reply] [Watch: Dir/Any] |
Just a random funny observation having done it myself a few times, taking a fully comprehensive "slice" of a hash like this sounds linguistically silly to me even though it's perfectly valid in the Perl language. Hmm... which is the better analogy? Is it like cutting a personal pizza in to slices and then proceeding to eat them all in one sitting, or more like just folding your one slice (the entire pizza) up like a calzone to eat it? After all, in the latter case you don't even need to get your pizza cutter dirty, that's just efficiency in practice. :-)
I wonder if there is a word in the English language for when a word that's technically correct is also simultaneously nonsensical, like here with the "slice" in fact being "the entire thing". Oxymoron or misnomer don't seem quite right, because strictly speaking there aren't any contradictory terms involved and "slice" is still the correct name. Are there any logophile Monks with suggestions? (I cross posted on Stack Exchange since it's admittedly a bit off topic here)
Just another Perl hooker - Working on the corner... corner conditions that is.
| [reply] [Watch: Dir/Any] |
| [reply] [Watch: Dir/Any] |
There's nothing nonsensical about it. The largest subset is always equal to the full set.
| [reply] [Watch: Dir/Any] |