rampant selectrow_array misuse

Frédéric Buclin LpSolit at gmail.com
Fri Aug 26 12:01:26 UTC 2005


Gervase Markham a écrit :

> "This utility method combines prepare, execute and fetchrow_array into a 
> single call. If called in a list context it returns the first row of 
> data from the statement. If called in a scalar context it returns the 
> first field of the first row."

Yes, I confirm that, see 
/usr/lib/perl5/vendor_perl/5.8.6/i386-linux/DBI.pm, line 1545:

     sub selectrow_array {
	my $row = _do_selectrow('fetchrow_arrayref', @_) or return;
	return $row->[0] unless wantarray;
	return @$row;
     }

Note the presence of 'wantarray'! :) So what we have done so far is 
correct as long as we are not in the "special" 'while ()' condition 
justdave talked about earlier.

No reason to hold approval anymore, justdave. ;)



More information about the developers mailing list