For Programmers: Free Programming Magazines  


Home > Archive > PERL CGI Beginners > September 2005 > File Modification Date









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author File Modification Date
Vance M. Allen

2005-09-14, 6:55 pm

I'm trying to find out how to determine the date and/or time that a file was
created in a simple procedure. I have heard about a few different libraries
but the examples I have found haven't been very useful.

The basic purpose I want to do is a simple footer provided by a package
module through CGI to inform users of the latest update to the code based on
the URL. Something simple saying "Version x.xx, Last Modified MM/DD/YYYY."
which would automatically get the file modified timestamp.

I'd prefer to have, if possible, a simple scalar variable to store the
date...for example:

$modtime = filemoddate_func(filename.cgi);

If anyone can help me with the libraries I need to use for this (if any
special), and a code snippet if possible, I'd really appreciate it.

Thanks!

Vance


Paul Archer

2005-09-14, 6:55 pm

perldoc -q timestamp


12:42am, Vance M. Allen wrote:

> I'm trying to find out how to determine the date and/or time that a file was
> created in a simple procedure. I have heard about a few different libraries
> but the examples I have found haven't been very useful.
>
> The basic purpose I want to do is a simple footer provided by a package
> module through CGI to inform users of the latest update to the code based on
> the URL. Something simple saying "Version x.xx, Last Modified MM/DD/YYYY."
> which would automatically get the file modified timestamp.
>
> I'd prefer to have, if possible, a simple scalar variable to store the
> date...for example:
>
> $modtime = filemoddate_func(filename.cgi);
>
> If anyone can help me with the libraries I need to use for this (if any
> special), and a code snippet if possible, I'd really appreciate it.
>
> Thanks!
>
> Vance
>
>
>
> --
> To unsubscribe, e-mail: beginners-cgi-unsubscribe@perl.org
> For additional commands, e-mail: beginners-cgi-help@perl.org
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
>
>


---------------------------------------
-- In 1555, Nostradamus wrote: --
-- Come the millennium, month 12, --
-- In the home of greatest power, --
-- The village idiot will come forth --
-- To be acclaimed the leader. --
---------------------------------------
Wiggins d'Anconia

2005-09-14, 6:55 pm

Vance M. Allen wrote:
> I'm trying to find out how to determine the date and/or time that a file was
> created in a simple procedure. I have heard about a few different libraries
> but the examples I have found haven't been very useful.
>
> The basic purpose I want to do is a simple footer provided by a package
> module through CGI to inform users of the latest update to the code based on
> the URL. Something simple saying "Version x.xx, Last Modified MM/DD/YYYY."
> which would automatically get the file modified timestamp.
>
> I'd prefer to have, if possible, a simple scalar variable to store the
> date...for example:
>
> $modtime = filemoddate_func(filename.cgi);
>
> If anyone can help me with the libraries I need to use for this (if any
> special), and a code snippet if possible, I'd really appreciate it.
>
> Thanks!
>
> Vance
>
>
>


Generally this type of information is provided by C<stat>, see,

perldoc -f stat

For the details.

To get the modification time for example you could use something like,

my $mod_time = (stat 'filename.cgi')[9];

File creation time is rarely if ever available. Obviously you could wrap
the above in a sub, but I suspect there isn't a lot of reason to since
it is so short anyways.

HTH,

http://danconia.org
Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com