in reply to Re^2: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
in thread comparing 2 file time date stamps

anonymous_monk, I could not get that code to work. The Time-Piece was not available in the repositories PPM checked. I tried with File-Stat and got several PM dependency messages.

I apologize for not using these facilities as I should sometimes. My lack of experience is showing.

I tried reversing the file order in the diagnostics. The stat 9 values for both tests were still the values of the file not in the staging directory, in this case now the 2nd file in the diagnostic order. I don't seem to be able to see the file in the staging area.

  • Comment on Re^3: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )

Replies are listed 'Best First'.
Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by Anonymous Monk on Nov 04, 2014 at 13:18 UTC
      I get the following error when I try to execute that subroutine

      path" is not exported by the Path::Tiny module\nCan't continue after import

      I use -

      use File::stat;
      use Path::Tiny qw/ path /;
      use File::Spec;

        path" is not exported by the Path::Tiny module\nCan't continue after import

        All you need is  use Path::Tiny; ... newer versions of Path::Tiny allow typing  use Path::Tiny 'path'; which documents where path() comes from

        Path::Tiny uses File::stat and File::Spec automagically ... stick with the path() api, and get the latest version for the most features and bug fixes

        Both modules are shown as available via ppm http://code.activestate.com/ppm/Path-Tiny/ and http://code.activestate.com/ppm/Time-Piece/

Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by craigt (Acolyte) on Nov 04, 2014 at 13:49 UTC
    I tried
    use File::stat; use Time::localtime; $dd[11] = ctime(stat("$xxfn1")->mtime); $dd[12] = ctime(stat("$xxfn2")->mtime);
    The result was for both files

    Mon Nov 3 11:57:55 2014

    which is the stamp of the file not in the staging directory.

    All methods seem to return the same modification date for both files, even though the file dates are 11/3 and 11/2, respectively.

      I tried ... stuff I did not recommend

      Sorry dude :) Time::Piece is the core module with the neato API that stop you from having to do + 1900 nonsense ...

      $ perl -e " use Time::Piece; print localtime->year,$/ " 2014
Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by craigt (Acolyte) on Nov 04, 2014 at 13:53 UTC
    I tried
    use File::stat; use Time::localtime; $dd[11] = ctime(stat("$xxfn1")->mtime); $dd[12] = ctime(stat("$xxfn2")->mtime);
    The result for both files was

    Mon Nov 3 11:57:55 2014

    which is the stamp of the file not in the staging directory.

    All methods seem to return the same modification date for both files, even though the file dates are 11/3 and 11/2, respectively.

      I don't think you want or need the quotes around the file variables. These modules work, they must be being applied to files other than the ones you intend. What is the output if you add the following immediately before you use the ctime function?

      printf "File 1:%s File 2: %s\n", $xxfn1, $xxfn2;
      1 Peter 4:10
Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by craigt (Acolyte) on Nov 04, 2014 at 16:18 UTC
    The correct files names are printed.
Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by craigt (Acolyte) on Nov 04, 2014 at 16:21 UTC
    I'm working on an application on a Windows 7, Apache/2.0.64 (Win32), mod_perl/2.0.3, and Perl/v5.8.3 platform. This version of Perl has been rock solid, so I have not upgraded. If I do need to upgrade Perl, what version should I go to. I've written about 110K lines and the application is up under mod_perl without error. This is a very important function I use in several ways in several places.
Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by craigt (Acolyte) on Nov 04, 2014 at 16:26 UTC
    Also, stat seems to get hosed in memory and no longer returns any file information. I have to reboot to get stat to work again.
Re^4: comparing 2 file time date stamps ( Path::Tiny File::stat Time::Piece )
by craigt (Acolyte) on Nov 04, 2014 at 17:23 UTC
    I just looked at the date of the file in the staging area in javascript with the same result. stat 9 is not being used in this pass. The file in the staging area keeps showing a Nov 3 date and the external date is Nov 2.

    anonymous_monk, I don't see any way to respond as you requested. I'm sure its me. I only see an option to reply on the entry I've been using and those above on the page.

      Did you try removing the quotes around the file name variable? Run the following, verbatim, and post the results, verbatim. Where I have the ???, fill in the path and name of one of your files.

      use strict; use warnings; use File::stat; use Time::localtime; my $file = ???; printf "%s: %s\n", $file, ctime(stat($file)->mtime);
      1 Peter 4:10

        Your going to love this.

        Below is a result files from the examination of 12 files (base directory) with a similar file in a different (staging) directory. I ran this after I put your diagnostic suggestion in. The code is basically the same.

        I was excited because all the 1st and 2nd dates were different. However all the 2nd date time stamps are wrong. The date portion is right on one. I don't know were it got the 2nd dates. They make no sense.

        I'm not doing the copy in these tests, just examining the dates.

        When I reran this test, the file dates of each of the pairs were the same again. This is strange.

        Note: All first date time stamps are right.
        
        C:/Steep/USA Data/State/KY/KY2.gif
        C:/usr/www/steepusa/stage/KY/KY2.gif
        Wed Nov  5 19:52:00 2014
        Wed Nov  5 13:09:08 2014 wrong??? 11/4/2014
        2014115195200
        2014115130908
        
        C:/Steep/USA Data/State/KY/ef.gif
        C:/usr/www/steepusa/stage/KY/ef.gif
        Wed Nov  5 19:34:36 2014
        Mon Nov  3 10:49:15 2014 wrong??? actually 8/25/2012
        2014115193436
        2014113104915
        
        C:/Steep/USA Data/State/KY/KYfv.gif
        C:/usr/www/steepusa/stage/KY/KYfv.gif
        Wed Nov  5 19:54:05 2014
        Wed Nov  5 13:09:41 2014 wrong??? 8/25/2012
        2014115195405
        2014115130941
        
        C:/Steep/USA Data/State/KY//cprofs.gif
        C:/usr/www/steepusa/stage/KY/cprofs.gif
        Wed Nov  5 19:58:00 2014
        Tue Sep 30 07:32:58 2014 Date is right.  Time is wrong.  
        2014115195800
        2014930073258
        
        C:/Steep/USA Data/State/KY/Ideals/Health/Healthfv.gif
        C:/usr/www/steepusa/stage/KY/Healthfv.gif
        Wed Nov  5 18:18:20 2014
        Thu May 24 13:36:42 2012 wrong??? 8/25/2012
        2014115181820
        2012524133642
        
        C:/Steep/USA Data/State/KY/KY.gif
        C:/usr/www/steepusa/stage/KY/KY.gif
        Wed Nov  5 19:51:52 2014
        Wed Nov  5 13:08:57 2014 wrong??? 11/4/2014
        2014115195152
        2014115130857
        
        C:/Steep/USA Data/State/KY/kyseal.gif
        C:/usr/www/steepusa/stage/KY/kyseal.gif
        Wed Nov  5 19:54:15 2014
        Fri Aug 17 10:35:10 2012 wrong??? 8/25/2012
        2014115195415
        2012817103510
        
        C:/Steep/USA Data/State/KY/kyflag.gif
        C:/usr/www/steepusa/stage/KY/kyflag.gif
        Wed Nov  5 19:52:19 2014
        Tue Nov  4 17:03:34 2014 wrong??? 8/25/2012
        2014115195219
        2014114170334
        
        C:/Steep/USA Data/State/KY/oldkyhome.gif
        C:/usr/www/steepusa/stage/KY/oldkyhome.gif
        Wed Nov  5 19:58:17 2014
        Fri Aug 17 10:35:11 2012 wrong??? 8/25/2012
        2014115195817
        2012817103511
        
        C:/Steep/USA Data/State/KY/kybird.gif
        C:/usr/www/steepusa/stage/KY/kybird.gif
        Wed Nov  5 19:52:08 2014
        Wed Nov  5 13:09:25 2014 wrong??? 8/25/2012
        2014115195208
        2014115130925
        
        C:/Steep/USA Data/State/KY/kyflower.gif
        C:/usr/www/steepusa/stage/KY/kyflower.gif
        Wed Nov  5 19:53:56 2014
        Fri Aug 17 10:35:10 2012 wrong??? 8/25/2012
        2014115195356
        2012817103510
        
        C:/Steep/USA Data/State/KY/kytree.gif
        C:/usr/www/steepusa/stage/KY/kytree.gif
        Wed Nov  5 19:54:26 2014
        Mon Nov  3 10:46:31 2014 wrong??? 8/25/2012
        2014115195426
        2014113104631
        
        I think that work. I have to do some more testing. I thought I tried ctime and got the same result. Thanks for prodding me again.