mumble jumbling.
Stray Toaster
mwk at stray-toaster.co.uk
Thu Jan 3 03:51:49 CST 2002
Hey, people.
I want to take an array, and then make another out of it, albeit a
jumbled up version. Now there is bound to be a nice way of doing this.
Here is what I have.....
#!/usr/bin/perl -w
use strict;
my $jumble = sub {
my @l = @_; my @s;
push @s, splice @l, int rand scalar @l, 1 for (1 .. scalar @l);
return @s;
};
my @ary = (1, 2, 3, 4, 5, 6, 7, 8, 9, 0);
print "$_ " foreach @ary;
print "\n\n";
print "$_ " foreach $jumble->(@ary);
print "\n\n";
ick. Any better suggestions?
m.
--
So they went off together. But wherever
they go, and whatever happens to them on the way,
in that enchanted place on the top of the Forest
a little boy and his Bear will always be playing.
More information about the Belfast-pm
mailing list