How does a perl script get the last-modified date of a file?

Discussion in 'Perl' started by Rich Pasco, Oct 9, 2003.

  1. Rich Pasco

    Rich Pasco Guest

    The PERL statement I use to open a text file looks like this:
    open(HANDLE, $filename);
    Now how can I get the "last modified" date of that file?
    I need a solution that works the same under Windows or Unix.

    - Rich
     
    Rich Pasco, Oct 9, 2003
    #1
    1. Advertising

  2. Gunnar Hjalmarsson, Oct 9, 2003
    #2
    1. Advertising

  3. Rich Pasco

    Rich Pasco Guest

    Gunnar Hjalmarsson wrote:

    > Rich Pasco wrote:
    >> The PERL statement I use to open a text file looks like this:
    >> open(HANDLE, $filename);
    >> Now how can I get the "last modified" date of that file?
    >> I need a solution that works the same under Windows or Unix.

    >
    > my $date = localtime( (stat HANDLE)[9] );
    >
    > http://www.perldoc.com/perl5.8.0/pod/func/stat.html


    Perfect, thanks!

    - Rich
     
    Rich Pasco, Oct 9, 2003
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Marc Mendez

    File last modified date wrong

    Marc Mendez, Aug 21, 2007, in forum: Java
    Replies:
    8
    Views:
    1,104
    Roedy Green
    Aug 23, 2007
  2. Roedy Green

    Date last Accessed vs Date Modified

    Roedy Green, Feb 21, 2008, in forum: Java
    Replies:
    1
    Views:
    1,467
    Nigel Wade
    Feb 22, 2008
  3. Elliot
    Replies:
    1
    Views:
    315
    siccolo
    Feb 27, 2008
  4. Elliot
    Replies:
    3
    Views:
    364
    Elliot
    Jun 16, 2008
  5. Arvin Portlock

    Using LWP to get last modified date of web page

    Arvin Portlock, Jun 4, 2004, in forum: Perl Misc
    Replies:
    4
    Views:
    370
    Richard Bell
    Jun 8, 2004
Loading...

Share This Page