keafb has asked for the wisdom of the Perl Monks concerning the following question:

This node falls below the community's threshold of quality. You may see it by logging in.

Replies are listed 'Best First'.
Re: Display A File Via Attribute
by bikeNomad (Priest) on Jun 05, 2001 at 21:41 UTC
    I don't know how you can tell what is a "report" or what "last modified date" refers to. But you can use File::Find in Perl (sorry, not PERL) to find .shtml files that were modified in the last 30 days:

    #! /usr/local/bin/perl -w eval 'exec /usr/local/bin/perl -S $0 ${1+"$@"}' if 0; #$running_under_some_shell use strict; use File::Find (); # Traverse desired filesystems File::Find::find({wanted => \&wanted}, '.'); exit; sub wanted { my ($dev,$ino,$mode,$nlink,$uid,$gid); return unless /^.*\.shtml\z/s && (($dev,$ino,$mode,$nlink,$uid,$gid) = lstat($_)) && (int(-M _) < 30); # now do whatever you want with the file named # by $File::Find::name # this is probably not what you want to do: print("$File::Find::name\n"); }
    This, by the way, was edited from the output of find2perl:

    $ find2perl . -name "*.shtml" -mtime -30
    update: changed unlink to print
      this is to keafb, as you've said you're very new to perl :

      DO NOT RUN THIS CODE AS IS


      See that unlink at the end? that'll delete every file it comes across that matches the regex /^.*\.shtml\z/s. Beware.
      You might want to change it to print ... or something else until you can understand what's going on.

      note to others : I know that bikeNomad warned him, but I think a larger warning couldn't hurt in this case, ok?

        Sorry. I changed it.
Re: Display A File Via Attribute
by Beatnik (Parson) on Jun 05, 2001 at 22:02 UTC
    #!/usr/bin/perl -w use strict; foreach(<*.shtml>) { if (-M $_ < 31) { print $_,"\n"; } }
    would probably do :)

    Greetz
    Beatnik
    ... Quidquid perl dictum sit, altum viditur.
      Except that it doesn't recurse into directories.
        Yeah, true =) missed that bit :)

        Greetz
        Beat-'dont make me break out my crappy, buggy, old directory recursion routine'-nik
        ... Quidquid perl dictum sit, altum viditur.
        On a related note, File::Find doesn't behave when called from an ASP script in ActiveState's implementation. I think it is having trouble chdir'ing, and can't traverse. I ended up having to code without it.