Hi fellow monks! Anyone offering perls of wisdom? Basically, I have populated this hash with ip addresses for key values and corresponding file names for list values. The purpose, is to upload various files to different ftp servers based on ip ranges. This script is currently in production, but there are some doubts to whether we are getting duplicate files around midnight. The script kicks off by cron every 5 min., and files are coming into to this server (via tftp) all the time. My question is, does the file test operator -M (see 2 lines ### LOOK HERE ### AND HERE) evaluate properly if the script kicks off prior to midnight, let's just say 23:56:00, but it is 00:01:59 when the script gets around to check the last modified date of the file, which turns out to be last modified (the file) at 23:59:59? Basically, the question is, does -M work if spanned across midnight? Does -M evaluate based on the date value in addition to the time value (min,seconds)? I guessing, it evaluates in terms of seconds (or even milliseconds?) based on the UNIX time since 19xx or something like that. Please, someone make me look like the fool that I am!
#use Shell; use Symbol; use IO::Handle; #use Data::Dumper; use Net::FTP; #use File::Copy; my @bsips = qw( 192.168.1.132 192.168.1.133 192.168.1.134 192.168.1.135 ); my @ipsegs = qw( 10.10.10 10.20.20 10.30.30 10.40.40 ); my $uid = "user"; my $pwd = "password"; my $rdir = "/rdir/data"; my $ldir = "/ldir/data"; my $tmpdir = "/opt/perl/tmp"; my $pathlog = "/opt/perl/tmp/ftp.log"; ## more subs here, not included (hash population) sub ftp2bs { ($uid, $pwd, $rdir, $ldir, $pathlog, $bsips, $hbs) = @_; for $gx (keys %$hbs) { #print "$gx ------------- $gx\n"; chdir "$ldir" or die "error: $!\n"; $ftp=Net::FTP->new($gx); neterr($ftp); $ftp->login($uid,$pwd); neterr($ftp); $ftp->binary(); neterr($ftp); $ftp->cwd($rdir); neterr($ftp); for $i (0..$#{$hbs{$gx}}) { my $fnx = $hbs{$gx}[$i]; ### LOOK HERE if (-w $ldir."/".$fnx && -M $ldir."/".$fnx>0.0007) { #print "$gx: $hbs{$gx}[$i]\n"; $ftp->put($ldir."/".$fnx); # print $ftp->message(), ""; # neterr($ftp); } } $ftp->close; neterr($ftp); $ftp->quit; neterr($ftp); } } sub io4ls { ($tmpdir, $pathlog, $hbs) = @_; for $gx (keys %$hbs) { my $fhw = gensym; open $fhw, ">>$tmpdir/$gx.list" or die "error: $!\n"; #print "$gx ------------------- $gx\n"; for $i (0..$#{$hbs{$gx}}) { my $fnx = $hbs{$gx}[$i]; ## AND HERE if (-w $ldir."/".$fnx && -M $ldir."/".$fnx > 0.0007) { #print "$gx: $hbs{$gx}[$i]\n"; print $fhw "$hbs{$gx}[$i]\n"; } } close $fhw; } } ftp2bs($uid, $pwd, $rdir, $ldir, $pathlog, \@bsips, \%hbs); io4ls($tmpdir, $pathlog, \%hbs);

In reply to file test modifier -M and midnight rollover by trowa

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.