CGI/Perl Guide | Learning Center | Forums | Advertise | Login
Site Search: in

  Main Index MAIN
INDEX
Search Posts SEARCH
POSTS
Who's Online WHO'S
ONLINE
Log in LOG
IN

Home: Perl Programming Help: Beginner: Re: [StarkRavingCalm] Compare unchanged files in two arrays: Edit Log



FishMonger
Veteran / Moderator

Jan 8, 2013, 11:51 AM


Views: 3537
Re: [StarkRavingCalm] Compare unchanged files in two arrays

Use hashes instead of arrays.

Comparing filesize is not the best way to determine if the file has been changed. You should compare the contents. The best approach to that would be to generate an md5 checksum and compare those.

So, your hash keys will be the filenames and the value of each is the md5 checksum/digest.

Digest::MD5
http://search.cpan.org/~gaas/Digest-MD5-2.52/MD5.pm

Another choice would be File::Checksum
http://search.cpan.org/~knorr/File-Checksum-0.01/Checksum.pm


(This post was edited by FishMonger on Jan 8, 2013, 11:54 AM)


Edit Log:
Post edited by FishMonger (Veteran) on Jan 8, 2013, 11:53 AM
Post edited by FishMonger (Veteran) on Jan 8, 2013, 11:54 AM
Post edited by FishMonger (Veteran) on Jan 8, 2013, 11:54 AM


Search for (options) Powered by Gossamer Forum v.1.2.0

Web Applications & Managed Hosting Powered by Gossamer Threads
Visit our Mailing List Archives