note
imp
The problem is that while does not iterate over a list, it simply checks for a true value. For example, <code>while (1){}</code> will run forever, whereas <code>for (1){}</code> will run once.
<p>
The same behaviour occurs when test being evaluated is <code>param()</code>. Additionally, <code>while (param()){}</code> will not modify $_. Perhaps you tested the script without any arguments, in which case it would have behaved as expected.
<p>
Here is a simple test:
<code>
#!/usr/bin/perl
use strict;
use warnings;
use CGI qw(param);
my $runs =0;
my @num;
print "Content-type: text/plain\n\n";
while(param()) {
printf "run %d\n", $runs++;
if ($runs > 10) {
print "Ran over 10 times\n";
exit;
}
}
</code>
You can verify it by adding the parameters on the commandline, e.g.
<code>
perl foo.pl a=b
</code>
619707
621839