Poll answers are now randomizable.

This commit is contained in:
JT Smith 2002-08-01 02:47:03 +00:00
parent 5c903b5c39
commit 80d9099815
3 changed files with 29 additions and 6 deletions

View file

@ -15,7 +15,7 @@ use strict;
use Tie::IxHash;
our @ISA = qw(Exporter);
our @EXPORT = qw(&sortHashDescending &sortHash &isIn &randint &round);
our @EXPORT = qw(&randomizeArray &sortHashDescending &sortHash &isIn &randint &round);
#-------------------------------------------------------------------
sub isIn {
@ -47,6 +47,17 @@ sub randint {
return $low + int( rand( $high - $low + 1 ) );
}
#-------------------------------------------------------------------
sub randomizeArray {
my ($array, $i, $j);
$array = shift;
for ($i = @$array; --$i; ) {
$j = int rand ($i+1);
next if $i == $j;
@$array[$i,$j] = @$array[$j,$i];
}
}
#-------------------------------------------------------------------
sub round {
return sprintf("%.0f", $_[0]);