#!/usr/bin/perl -w use strict; use Digest::MD5; my @fileary; $fileary[0] = { name => '', oldhash => '', newhash => '' }; $fileary[1] = { name => '', oldhash => '', newhash => '' }; while (1) { foreach (@fileary) { # move the newhash (from last iteration) to the oldhash of # this iteration %{$_}->{oldhash}=%{$_}->{newhash}; #check to see if there is a different has to #last iteration if (%{$_}->{newhash} ne %{$_}->{oldhash}) { print "File ".%{$_}->{name}." has changed\n"; } else { print "oldhash: ".%{$_}->{oldhash}.". newhash: ". %{$_}->{newhash}."\n"; } #go get a filehandle open (FILE, %{$_}->{name}) or die "Can't open '$_': $!"; #go get the hash of the file %{$_}->{newhash} =Digest::MD5->new->addfile(*FILE)->hexdigest; close FILE; } }