Look again!
Update: Maybe this will clarify things a little?
#! perl -sw
use strict;
sub shuffl (\@) {
my $r=pop;
for (0..$#{$r}) {
my $size = scalar @{$r};
my $choices = $size - $_;
printf 'iteration: %2d Size: %2d rand(%2d) range: %2d .. %
+2d %s',
$_, $size, $choices, $_, $cho
+ices + $_, $/;
$a = $_ + rand @{$r} - $_;
@$r[$_, $a] = @$r[$a, $_];
}
}
my @array = (1 ..15);
shuffl @array;
__END__
C:\test>210557
iteration: 0 Size: 15 rand(15) range: 0 .. 15
iteration: 1 Size: 15 rand(14) range: 1 .. 15
iteration: 2 Size: 15 rand(13) range: 2 .. 15
iteration: 3 Size: 15 rand(12) range: 3 .. 15
iteration: 4 Size: 15 rand(11) range: 4 .. 15
iteration: 5 Size: 15 rand(10) range: 5 .. 15
iteration: 6 Size: 15 rand( 9) range: 6 .. 15
iteration: 7 Size: 15 rand( 8) range: 7 .. 15
iteration: 8 Size: 15 rand( 7) range: 8 .. 15
iteration: 9 Size: 15 rand( 6) range: 9 .. 15
iteration: 10 Size: 15 rand( 5) range: 10 .. 15
iteration: 11 Size: 15 rand( 4) range: 11 .. 15
iteration: 12 Size: 15 rand( 3) range: 12 .. 15
iteration: 13 Size: 15 rand( 2) range: 13 .. 15
iteration: 14 Size: 15 rand( 1) range: 14 .. 15
C:\test>
Nah! You're thinking of Simon Templar, originally played (on UKTV) by Roger Moore and later by Ian Ogilvy
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|