Everyone,
Ok, I have been working on this for a few days now and I am confused. I'm able to get the epoch time from stat and determine which file is newer. Yet, when I use localtime to try and find the DMYHMS format to the same problem, I get nothing but errors. Can someone please help!

To give you some background. I have a remote server on the otherside of the world, I need to check the date on a file on the remote server, if the date is older then the one on my local server, copy the new file from the local server to the remote server.

I want to do all this by comparing either the date modified or the date changed that is time stamped onto the file.

Now here is the code for the stat. Which gets the epoch time and divides by 60,60,60,24,7 to get the time in epoch seconds since 1970.

#!/usr/bin/perl -w use File::Copy; $filename1 = "c:/progra~1/imms"; #file on the client (win +95/98). $filename2 = "//bmc_1/imms_stock/imms_exe/imms.exe"; #file on serve +r. @file1 = stat($filename1); #print "$file1[10]\n"; @file2 = stat($filename2); #print "$file2[10]\n"; $days1 = ((((($file1[10] /60) /60) /60) /24) /7); #print "$days1\n +"; $days2 = ((((($file2[10] /60) /60) /60) /24) /7); #print "$days2\n +"; if ($days1 < $days2) { print "$filename1 is old\n"; copy ($filename2, $filename1) or die "copy failed: $!\n"; print "$filename2 updated!\n"; }else{ print "$filename2 is up to date!\n"; print "No files copied!\n"; }

What I need is to break the epoch seconds down by using the localtime function. I have been looking at both the non-module way and the module way of doing this. I feel that I need to know the non-module way first. Especially for this project.

Here is what I have so far.

$filename1 = "u:/curtisbl/documents/conditional.sql.txt"; ($seconds, $minutes, $hours, $day_of_month, $month, $year, $wday, $yda +y, $isdst) = localtime($filename1); printf ("Time: %02d-%02d-%04d\n", $month+1, $day, $year+1900);

Could someone help please?

Curtisb

"Confused Dated Person"


In reply to stat and localtime by curtisb

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.