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

I am looking for a way to read a dirctory and get the modified date of the files in that directory. I have already modified a script to read the files in the directory and strip the <title> and </title> tags off and put the Title into a link on my page. Now I want the modified date of the file to be placed next to the Title. Is there a script that can do this? Or can someone help me out to modify my script to accomplish this?

UPDATE: This script is running on a Windows2K server and I tried Zaxo's suggestion and it did not work even without the USE POSIX::strftime. Is there some way to get this info on a Windows server. I can send the code if you wish.

I was also looking through my PM files and found a File.pm that should do the same as the POSIX. But Since I am new to working with Perl could someone help me as to how to use it and writing the code into what I alredy have?

Replies are listed 'Best First'.
Re: Directory Attributes
by Zaxo (Archbishop) on Dec 12, 2003 at 23:47 UTC

    Given the filename, use (stat $filename)[9] to extract mtime. Use POSIX::strftime to get the format you want from localtime appliet to the mtime.

    After Compline,
    Zaxo

      This script is running on a windows server and I tried your suggestion and it did not work even without the USE POSIX::strftime. I there some way to get this info on a Windows server. Ican send the code if you wish.