Hello Charlie, [snip] > =================================================== > > This is my function attempting to do the same thing(?). > > sub Comment() { > > my( $sth ); > > $sth = $dbh->prepare("SELECT comment from dbtable > where comment = 'whatever'") > or die "Can't query comment: $DBI::errstr\n"; > $sth->execute > or die "Can't execute comment: $DBI::errstr\n"; > return $sth->fetchrow_array();
Your differrence is here. You are returning only the first line of the '$sth->fetchrow_array()' of the prepared query where you do a while over all the returned elements of it in the other version. > } > =================================================== > > When I call the function like this it prints the first line over and > over, never getting the next line. > > my $comment; > > while ( $comment = Functions::Comment() ) { > print "$comment\n"; > } > ==================================================== [snip] I am using $sth->fetchrow_arrayref() as I have been told it is faster... my $comment = Functions::Comment(); # deref $comment which is actually our returned array @rows for my $row (@$comment) { # deref the returned items from '$sth->fetchrow_arrayref()' for(@$row) { # Print out all returned items print "$_\n"; } } sub Comment() { my $sth = $dbh->prepare("SELECT comment from dbtable where comment = 'whatever'") or die "Can't query comment: $DBI::errstr\n"; $sth->execute or die "Can't execute comment: $DBI::errstr\n"; my @rows; while ( my $rows = $sth->fetchrow_arrayref()) { # Push all returned refs into array @rows push @rows, $rows; } # return a ref to array @rows return(\@rows); } Shawn -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]