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

I need cron to regularly check a file (ie the /etc/sudoers file) for any changes. It could just test for checksum differences, but better if it tells what the change was. It'll be a good exercise for me (new to Perl), but I'm guessing it's already been done. No CPAN search is turning it up, though.

Any advice on how to go about this, or a pointer to something in CPAN is appreciated.

Thanks....Lyle

Replies are listed 'Best First'.
Re: checking a file for changes
by syphilis (Archbishop) on Sep 17, 2010 at 00:03 UTC
Re: checking a file for changes
by CountZero (Bishop) on Sep 17, 2010 at 06:03 UTC
    A general question causes general answers.

    Did you already have a look at Algorithm::Diff, Algorithm::Diff::Any, String::Diff or String::ShowDiff? Text::Diff also seems worth of being examined.

    CountZero

    A program should be light and agile, its subroutines connected like a string of pearls. The spirit and intent of the program should be retained throughout. There should be neither too little or too much, neither needless loops nor useless variables, neither lack of structure nor overwhelming rigidity." - The Tao of Programming, 4.1 - Geoffrey James

Re: checking a file for changes
by ww (Archbishop) on Sep 17, 2010 at 00:08 UTC
    As a newcomer (in nodes, if not time since you registered), you may want to read On asking for help and How do I post a question effectively?.

    Your post would benefit from actual code as opposed to mere speculation that checksum could satisfy a part of your requirement.

    And using search or Super Search or even Google (against this site alone), would lead you to several threads begun with much the same objective.

Re: checking a file for changes
by Khen1950fx (Canon) on Sep 17, 2010 at 23:02 UTC
    A good way to search perlmonks is to use Google. For example, I googled "check file for changes site:perlmonks.org", and this was the first page returned.