in reply to how to determine of fetchrow_Arrayref is empty?
if ( not( $ref ) ) { print "No results\n"; } else { # code to print results }
If I may offer some observations about the way you're doing this:
(1) The variable $numFields would be better named $number_fields. See perlstyle. And you might want to change "$ref" to "$aref" to indicate what kind of reference it is (myself, I'd probably call it $row, though I think Conway prefers $row_ref).
(2) The C-style for loop over the fields might be clearer if done in a more perl like way, just for example:
my $result = join ", ", @{ $ref }; print $result, "\n";
(3) Personally I lean towards fetchrow_hashref these days: the performance penalty on that was fixed a long time ago.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: how to determine of fetchrow_Arrayref is empty?
by ysth (Canon) on May 27, 2008 at 09:22 UTC | |
by doom (Deacon) on May 27, 2008 at 18:35 UTC |