$log = "log"; if ($list == 1)# one file to send { blah (this part works); } elsif ($list == 2) # multiple files to send { foreach $file (@initList) { $command = < $log; user $rem_user $rem_passwd mput $ftp_source_path[$i] $ftp_dest_path[$i] bye eof eod } }