good question. here are some sample scripts which should help...
the first one asks, how many elements are in a list if they are all undef
#!/usr/local/bin/perl
if ( (undef, undef) == 0 ) { print 'it is 0' }
run this, and you'll see that it prints 'it is 0'.
here's a second one that tests what happens when you get data back. it runs
11 times, and keeps going until it gets only undefs
#!/usr/local/bin/perl
my ($count, $thing, $otherthing);
while( ($thing, $otherthing) = &foo ) {
$count++;
}
print "the loop ran $count times\n";
sub foo {
return ( 1, 2 );
}
change the routine to this. it runs through the loop 0 times
sub foo {
return;
}
what if only 1 element is returned? it still runs 11 times.
sub foo {
return ( 1 );
}
what if 1 element is undef, but the second element is defined? it still
runs 11 times.
sub foo {
return (undef, 1 );
}
therefore, your code should work like you expect. i would still test it in
a test environment before making changes to prod.
Original Message:
-----------------
From: Greenhalgh David [EMAIL PROTECTED]
Date: Mon, 11 Aug 2003 21:13:39 +0100
To: [EMAIL PROTECTED]
Subject: Urgent Question (Deployed code gone wrong!)
A quick question about a while loop.
I have a simple code that searches database for all entries and puts
one of the fields into a select box on the output page. However, due to
a mistake in my untaint routine (which I've fixed) if a visitor entered
their name in Japanese characters, the entry into the data base is
blank. That means that my simple while loop:
while ($name=$sth->fetchrow_array()) {
print "<option>$name</option>";
}
stops when it hits the blank name. I can also select the ID number..
while (($name, $ID)=$sth->fetchrow_array()) {
print ."<option>$name</option>";
}
--------------------------------------------------------------------
mail2web - Check your email from the web at
http://mail2web.com/ .
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]