I'm trying to get a grip on functions. I want to connect to a database, execute a SELECT statement, and print each line where the criteria is met.
This does what I want. my $comment; while ( $comment = $sth->fetchrow_array) { print "$comment\n"; } =================================================== 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(); } =================================================== 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"; } ==================================================== I'm missing how the function is different from the original, or I am not understanding 'return'. -- Charlie Farinella [EMAIL PROTECTED] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]