in reply to Digest::MD5 seems to slow down script

As pointed out in the chatterbox, you could gain much by storing MD5 sums and file size + modification date, and on subsequent runs only recalculate it if size or modification time changes.

Additionally the construct md5_hex(<IN>) is not optimal, because it reads the file line by line (even though there is no reason to split it up into lines at all), and loads the whole thing into memory before starting to process. Using $ctx->addfile(*IN) (as described in the Digest::MD5 documentation) instead should be a lot faster.

Finally you should probably set binmode on the IN file handle.

Perl 6 - links to (nearly) everything that is Perl 6.