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

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Rich Pasco

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

    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

  • Gunnar Hjalmarsson

    #2
    Re: How does a perl script get the last-modified date of a file?

    Rich Pasco wrote:[color=blue]
    > 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.[/color]

    my $date = localtime( (stat HANDLE)[9] );



    --
    Gunnar Hjalmarsson
    Email: http://www.gunnar.cc/cgi-bin/contact.pl

    Comment

    • Rich Pasco

      #3
      Re: How does a perl script get the last-modified date of a file?

      Gunnar Hjalmarsson wrote:
      [color=blue]
      > Rich Pasco wrote:[color=green]
      >> 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.[/color]
      >
      > my $date = localtime( (stat HANDLE)[9] );
      >
      > http://www.perldoc.com/perl5.8.0/pod/func/stat.html[/color]

      Perfect, thanks!

      - Rich

      Comment

      Working...