my @email_list = (); open(LIST,'<',"email_database.txt") or die "$!\n"; while(){ chomp $_; push(@email_list,$_); } close(LIST); foreach my $address(@email_list){ sendmail($address); } sub sendmail{ my $address = $_[0]; # what should I use here? if( mail was sent ) {return true} }