#!/usr/bin/perl -w use strict; use Net::FTP; use Getopt::Long; my %opt = (); GetOptions( \%opt, "usr=s", "pwd=s", ); chdir("/home/export/data/"); @files = reverse ( map { split (/\s+/))[8]; } `ls -lrt Open_Trade_Summary*`); foreach my $file (@files[0..3]) { check_age($files); } sub check_age{ my $file = shift; ( (if -M $file) < .5 ) { print "$file is current - ok to send\n"; send_file($file); } else { print "No current data available\n"; } sub send_file{ my $file = shift; my $ftp = Net::FTP->new("ntbox01.host.org"); $ftp->login($opt{usr}, $opt{pwd}); $ftp->cwd($remDir); $ftp->put($file); $ftp->exit; }