Smoot Carl-Mitchell wrote:
On Tue, 30 Mar 2004 16:00:41 -0600
"JupiterHost.Net" <[EMAIL PROTECTED]> wrote:


I'd rewrite the way you're doing it:

 my @records = @{$dbh->selectall_arrayref($query)};
 print "Your search returned $#records results.";
 for(@records) {
   ...
 }


$#records returns the index of the last element in the array. @records
in scalar context returns the number of elements in the array. With
array indices starting at zero, #$records + 1 == @records.

Right I should have caught that, sorry for the mistake everyone. Lets try it again:

  my @records = @{$dbh->selectall_arrayref($query)};
  my $rec_count = $#records++;
  print "Your search returned $rec_count results.";
  for(@records) {
  ...
  }

HTH :)


-- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to