File test Operator for Directory Age

Discussion in 'Perl' started by RickB, Feb 6, 2004.

  1. RickB

    RickB Guest

    Folks,

    Sorry if this is too elemental. I am attempting to create some admin
    scripts, among them the ability to delete folders older than X days.
    Question: in the following code, what do I use to get the Age of a
    Directory? I am using AcivePerl on Windows XP and Windows 2K.

    use Win32;

    use Win32::NetResource;
    use Time::localtime;

    # windows utility script for administration of disk space: delete old
    # files/folders

    $Name='C:\\Temp\\test';

    if ( -d $Name )
    {
    # how to detect directory older than 2 weeks
    print "Got a directory","\n";
    }
    else
    {
    if (-M $Name > 14)

    {
    # do good things for files older than 2 weeks
    print "Got a file","\n";
    }
    }
    exit 0;

    Thank you in advance. I am new to Perl but am already a convert!
    RickB, Feb 6, 2004
    #1
    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. =?iso-8859-1?B?bW9vcJk=?=
    Replies:
    7
    Views:
    817
    Roedy Green
    Jan 2, 2006
  2. cylin
    Replies:
    6
    Views:
    575
    Mike Wahler
    Aug 19, 2003
  3. Hicham Mouline
    Replies:
    2
    Views:
    691
    Juha Nieminen
    Sep 1, 2009
  4. Skybuck Flying

    Call oddities: &Test() vs &Test vs Test

    Skybuck Flying, Oct 4, 2009, in forum: C Programming
    Replies:
    1
    Views:
    690
    Skybuck Flying
    Oct 4, 2009
  5. Brynn

    OK ... AGE FUNCTION TEST RESULTS ...

    Brynn, Jan 11, 2004, in forum: ASP General
    Replies:
    1
    Views:
    135
    Brynn
    Jan 12, 2004
Loading...

Share This Page