Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Directory listing for a date range

by jhs3 (Novice)
on Jan 11, 2007 at 17:14 UTC ( #594202=perlquestion: print w/replies, xml ) Need Help??

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

I have been searching the archives and found a few similar questions...and answers. But, maybe some good monk can help me with this.

I want to be able to look at directory (a program source directory) and list the files with a changed date within a calendar month. I will tell the script which month and which directory. I then need to add the resulting file to a text file, checking if I had already put the file there for the same date: I would need to run the script daily, so the same file would likely already be in the text file. But, if a program source file has changed more than once within the month, I'd want to add another entry in the text file.

The code needs to work in both a Unix (HP / ksh) and Windows NT environment.

FYI: this is something being foist on me because of Sarbane-Oxley requirements. So this sort of search may already being used by someone else that is plagued by SOX.
(funny how SOX is a 4-letter word...)

Replies are listed 'Best First'.
Re: Directory listing for a date range
by Fletch (Chancellor) on Jan 11, 2007 at 19:10 UTC

    Most good SCM systems (Subversion, Perforce, et al) will keep this kind of information automagically and then it's just a matter of judicious parsing of the output from svn log or the like to produce a report. And you really should be using some form of SCM anyhow, so why bother with the record-keeping yourself?

    And condolences on the SOX thing; I've felt and continue to feel said pain. %/

Re: Directory listing for a date range - use a versioning system
by imp (Priest) on Jan 11, 2007 at 19:33 UTC
    Knowing which files have changed really isn't sufficient. You need to be able to identify what changed, who changed it, and preferrably with what intent - all things that versioning systems will do better than any script you hack together. Save yourself a lot of heartarche and invest some time in learning to use a versioning system. My current preference is subversion, with Trac as a web frontend.

    I listed some of my reasons for advocating versioning systems in a recent node.

Re: Directory listing for a date range
by jettero (Monsignor) on Jan 11, 2007 at 17:45 UTC
    Without getting into specific implementation details; personally, I'd store a Digest::SHA1 hash along with a file size and date stamp in a file or database table. There is a risk of collisions, but it's probably pretty small if you also compare the file size.

    To make sure it worked right even when there were no databases to connect to, I'd probably use DB_File or Storable. Even DBD::SQLite would be an excellent choice for that. I think it's largely a matter of preference, but if you like the look of Storable.pm, be sure to think about splitting it up by month and/or directory. Otherwise, reparsing that file into memory every time the program runs could get expensive.

    Then, when you need to generate file change reports, you can just work off the simple database and you're done!

    -Paul

OT: tripwire or aide to satisfy SOX.
by osunderdog (Deacon) on Jan 11, 2007 at 18:50 UTC

    In the past, I've considered installing tripwire or aide (see google) so that I could prove that a sys admin had modified something on a production system without proper notification. These tools might be used to handle SOX requirements.

    Hazah! I'm Employed!

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://594202]
Approved by willyyam
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others about the Monastery: (2)
As of 2021-01-17 07:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?