[root@devel3 root]# cat test.pl #!/usr/bin/perl my $dat = '/tmp/dat'; my $dir = '/root/'; if ( -e $dat ) { `ls -al $dir > $dat.current`; if ( `cat $dat` eq `cat $dat.current` ) { print "Dir $dir probably unchanged!\n"; } else { print "Dir $dir has changed\n", `diff -b $dat $dat.current`; `cat $dat.current > $dat`; } } else { `ls -al $dir > $dat`; # first pass init } [root@devel3 root]# ./test.pl # init stage [root@devel3 root]# ./test.pl Dir /root/ probably unchanged! [root@devel3 root]# touch foo [root@devel3 root]# ./test.pl Dir /root/ has changed 22a22 > -rw-r--r-- 1 root root 0 Feb 17 20:57 foo [root@devel3 root]# touch test.pl [root@devel3 root]# ./test.pl Dir /root/ has changed 56c56 < -rwxr-xr-x 1 root root 385 Feb 17 20:57 test.pl --- > -rwxr-xr-x 1 root root 385 Feb 17 20:58 test.pl [root@devel3 root]#