my @built; my @files = get_files_to_build(); for (@files) { my $built = build_file($_); unless ($built) { warn "Could not build $_!\n"; next; } my $filename = File::Spec->catfile($path, $_); open(OUTPUT, "> " . $filename) or die "Can't open $filename: $!"; print OUTPUT $built; push @built, [ $filename, $_ ]; } my $ftp = Net::FTP->new($remotehost, Debug => 1) or die "Can't connect to $remotehost: $@\n"; $ftp->login($username, $password) or die "Couldn't authenticate!\n"; $ftp->cwd('www'); foreach my $updated (@built) { my ($location, $name) = @$updated; $ftp->put($name, $location) or warn "Couldn't put $name: $@\n"; } $ftp->quit();