my $SENDTO = ""; # start with empty string while (my @row = $sth->fetchrow_array) { # retrieve one row if($row[1]=~/math/i){ $SENDTO .= "emailing $row[2]\n"; push(@SENDTO, $row[2]); } } $log = $SENDTO; &log_it;