#!C:/perl/bin/perl.exe use CGI::Carp qw(fatalsToBrowser); use CGI; $query = new CGI; $pass= $query->param('pass'); $v1= $query->param('v1'); $v2= $query->param('v2'); $v3= $query->param('v3'); $v4= $query->param('v4'); if($pass < 1){ $pass = 0; } print $query->header; print $query->start_html(-title=>'randomization'); print ""; if($pass == 1){ @randConditions = &randomize($v1,$v2,$v3,$v4); print "The original set of of items was $v1,$v2,$v3,$v4.
"; print "The randomized array of items is @randConditions.
"; } if($pass == 0){ print "
"; print "Type 4 numbers click the button to see their order randomized.
"; print "
"; print "
"; print "
"; print "
"; print ""; print ""; print "
"; } print $query->end_html; # ----------------- Subroutines ----------------------------- # for a good tutorial/overview of Perl subroutines, see # http://www.comp.leeds.ac.uk/Perl/subroutines.html #------------------------------------------------------------ sub randomize { # this subroutine randomizes the elements of an array and returns the new array srand; my(@new) = (); while (@_){ push(@new, splice(@_, rand @_,1)); } return @new; }