To find duplicate files, you can use the module File::Find::Duplicates. Here's a script that uses it, it could serve you as an example or you can use it as-is).
Alternatively, you can use an external application, like fdupes (it's in Debian repositories).
Comment on Re: Retaining the most recent file in a FS