B
Bill H
I am using the following snippet of code to rotate a list starting at a
random postion and it seems to run real slow (it works the way I want
it to), can someone tell me how it can be improved?
sub RotateList
{
my $results = "";
my $srq = rand(@rotquest);
my $i = 0;
my $j = 0;
for($i = 0;$i < @rotquest;$i++)
{
$j = $srq;
$srq++;
if ($srq >= @rotquest){$srq = 0;}
$results .= $rotquest[$j];
}
return ($results);
}
And here is how I enter the routine:
@rotquest = (
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED1" VALUE="An
automobile manufacturer or dealer ">An automobile manufacturer or
dealer<BR>~,
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED2" VALUE="A
market research company">A market research company<BR>~,
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED3" VALUE="A
newspaper or TV station">A newspaper or TV station<BR>~,
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED4" VALUE="An
advertising agency">An advertising agency<BR>~);
$q4 = &RotateList();
$q4 .= qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED5"
VALUE="None of the above">None of the above\n~;
I am not concerned that it isn't returning a list since I just then
dump the results out to a web page.
Bill H www.ts1000.us
random postion and it seems to run real slow (it works the way I want
it to), can someone tell me how it can be improved?
sub RotateList
{
my $results = "";
my $srq = rand(@rotquest);
my $i = 0;
my $j = 0;
for($i = 0;$i < @rotquest;$i++)
{
$j = $srq;
$srq++;
if ($srq >= @rotquest){$srq = 0;}
$results .= $rotquest[$j];
}
return ($results);
}
And here is how I enter the routine:
@rotquest = (
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED1" VALUE="An
automobile manufacturer or dealer ">An automobile manufacturer or
dealer<BR>~,
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED2" VALUE="A
market research company">A market research company<BR>~,
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED3" VALUE="A
newspaper or TV station">A newspaper or TV station<BR>~,
qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED4" VALUE="An
advertising agency">An advertising agency<BR>~);
$q4 = &RotateList();
$q4 .= qq~ <INPUT TYPE=CHECKBOX NAME="EMPLOYED5"
VALUE="None of the above">None of the above\n~;
I am not concerned that it isn't returning a list since I just then
dump the results out to a web page.
Bill H www.ts1000.us