hours since file creation

Discussion in 'Perl Misc' started by cooldaddy, Aug 20, 2005.

  1. cooldaddy

    cooldaddy Guest

    Im looking for some CGI code to find out how many hours have past since
    a file has been created or has been modified. Hope you guys/gals can
    help me.
     
    cooldaddy, Aug 20, 2005
    #1
    1. Advertising

  2. cooldaddy wrote:
    > Im looking for some CGI code to find out how many hours have past since
    > a file has been created or has been modified. Hope you guys/gals can
    > help me.


    What makes you think the mechanism to look at file attibutes would be
    different in a CGI environment? (I suspect you may be having difficulty
    partitioning your problem).

    The Perl -M operator tells you time (in days) from the last modified
    time of a file to the start of script execution.

    On Unix the -C operator does the same for the inode change time. There's
    no concept of creation date in POSIX and if you are using a filesystem
    with this concept you'll need filesystem dependant ioctl()s or external
    binaries.

    I think on Windows with NTFS -C will look at the creation date.
     
    Brian McCauley, Aug 20, 2005
    #2
    1. Advertising

  3. cooldaddy

    cooldaddy Guest

    Ok, thanks Brian,

    So I have to use the -M operator. Can you or someone else give me an
    example how to implement this in a cgi script ? I've searched the whole
    internet but cant find an cgi example.
     
    cooldaddy, Aug 20, 2005
    #3
  4. "cooldaddy" <> wrote in
    news::

    > Ok, thanks Brian,


    [ Please quote appropriately when posting a reply ]

    > So I have to use the -M operator. Can you or someone else give me an
    > example how to implement this in a cgi script ?


    As Brian also asked, what makes you think anything should be different in
    a CGI script?

    > I've searched the whole internet but cant find an cgi example.


    Use the documentation available to you on your computer:

    perldoc -f -x

    Sinan

    --
    A. Sinan Unur <>
    (reverse each component and remove .invalid for email address)

    comp.lang.perl.misc guidelines on the WWW:
    http://mail.augustmail.com/~tadmc/clpmisc/clpmisc_guidelines.html
     
    A. Sinan Unur, Aug 20, 2005
    #4
  5. "cooldaddy" <> writes:

    > Ok, thanks Brian,


    Thanks for what? Please quote enough context for your reply to make sense.

    > So I have to use the -M operator. Can you or someone else give me an
    > example how to implement this in a cgi script ?


    The same way you would in a non-cgi script.

    > I've searched the whole internet but cant find an cgi example.


    Did you try reading the docs that come with the language you're using?

    perldoc -q "file's timestamp"

    sherm--

    --
    Cocoa programming in Perl: http://camelbones.sourceforge.net
    Hire me! My resume: http://www.dot-app.org
     
    Sherm Pendley, Aug 20, 2005
    #5
  6. cooldaddy wrote:

    > So I have to use the -M operator. Can you or someone else give me an
    > example how to implement this in a cgi script ? I've searched the whole
    > internet but cant find an cgi example.


    OK, that's a distinctly odd request but since you ask...

    use strict;
    use warnings;

    print "Content-type: text/plain\n\n";

    print "The file foo is ",( -M 'foo' )," days old";
    __END__

    And just how were you expecting that to help?
     
    Brian McCauley, Aug 20, 2005
    #6
    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. tdi1686
    Replies:
    2
    Views:
    375
    Kevin Spencer
    Aug 13, 2003
  2. Rahmi Acar
    Replies:
    0
    Views:
    564
    Rahmi Acar
    Jul 17, 2003
  3. Replies:
    3
    Views:
    315
    Tim Williams
    Mar 30, 2007
  4. Dirk Hagemann
    Replies:
    18
    Views:
    1,303
  5. rutherf
    Replies:
    2
    Views:
    432
    rutherf
    Oct 28, 2006
Loading...

Share This Page