in reply to random elements from array - new twist
One way would be to shuffle the elements of the array and then use a slice to assign them to your vars.
sub shuffle (\@) { my $r=pop; $a = $_ + rand @{$r} - $_ and @$r[$_, $a] = @$r[$a, $_] for (0..$#{$r}); } my @array = (1..15); shuffle(@array); my ($comp1, $comp2, $comp3, $comp4, $comp5) = @array[0..4];
Nah! Your thinking of Simon Templar, originally played by Roger Moore and later by Ian Ogilvy
In Section
Seekers of Perl Wisdom