while (<>) { chomp; # can't remember if this is necessary or not my $domain = $_; &send_file_to($domain) or warn "Couldn't send file to $_"; # your subroutine }