Use the three-argument form of open()

This separates the openmode from the filename, and is both clearer
and safer.
Use Digest::MD5 instead of shelling out

It's in Perl's core distribution, so this doesn't add a dep.