in reply to Re: Newbie: need algorithm to evaluate no file exist
in thread Newbie: need algorithm to evaluate no file exist

Two small tweaks (for the OP, really).
push @files, $ftp->ls; my $new_file = 0; my $current_time_epoch = time; for my $file (@files) { my $modified_time_epoch = $ftp->mdtm($file); if ( ($current_time_epoch - $modified_time_epoch) <= 3600 ) { print "$file\n"; print "Current time = $current_time_epoch\n"; print "MDTM = $modified_time_epoch\n"; $new_file = 1; } } envia_mail() if !$new_file; $ftp->quit or die $ftp->message;

If those print statements are just for debugging purposes, you can exit the loop early.

push @files, $ftp->ls; my $new_file = 0; my $current_time_epoch = time; for my $file (@files) { if ( ($current_time_epoch - $ftp->mdtm($file) ) <= 3600 ) { $new_file = 1; last; } } envia_mail() if !$new_file; $ftp->quit or die $ftp->message;

Replies are listed 'Best First'.
Re^3: Newbie: need algorithm to evaluate no file exist
by Anonymous Monk on Aug 18, 2010 at 15:39 UTC

    Thanks Ikegami, you're right on all your suggestions. as a newbie i'm very confuse,but i'm RTFM. Thanks again

      You don’t need to apologize.   :-)

      “This bald-spot over here?   Why, that happened when I ripped my hair out trying to solve this problem!   And that bald-spot over there...”

      P.S.   Even if it’s not actually true, it sure beats the hell out of admitting that you’re just getting old!   :-D