my $count = 0; my @sent; while (get_entry_from_db()){ if (/match/){ ...; # send email and do other stuff $count++; push @sent, [$contact, $email]; } } print "users mailed: $count\n"; for my $entry (@sent){ my ($contact, $email) = @$entry; print "email sent to: $contact <$email>
"; }