Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
package File::Find::Duplicates; =head1 NAME File::Find::Duplicates - Find duplicate files =head1 SYNOPSIS use File::Find::Duplicates; my %dupes = find_duplicate_files('/basedir'); local $" = "\n "; foreach my $filesize (keys %dupes) { print "Duplicate files of size $filesize:\n @{$dupes{$filesize}}\ +n"; } =head1 DESCRIPTION This module provides a way of finding duplicate files on your system. When passed a base directory (or list of such directories) it returns a hash, keyed on filesize, of lists of the identical files of that siz +e. =head1 TODO Provide some much more useful interfaces to this. =head1 AUTHOR Tony Bowden, tony@blackstar.co.uk =head1 SEE ALSO File::Find =cut use vars qw($VERSION @ISA @EXPORT %files); require Exporter; @ISA = qw/Exporter/; @EXPORT = qw/find_duplicate_files/; $VERSION = '0.02'; use strict; use File::Find; use Digest::MD5; sub check_file { -f && push @{$files{(stat(_))[7]}}, $File::Find::name; } sub find_duplicate_files { my %dupes; find(\&check_file, shift || "."); foreach my $size (sort {$b <=> $a} keys %files) { next unless @{$files{$size}} > 1; my %md5; foreach my $file (@{$files{$size}}) { open(FILE, $file) or next; binmode(FILE); push @{$md5{Digest::MD5->new->addfile(*FILE)->hexdigest}},$file; } foreach my $hash (keys %md5) { push @{$dupes{$size}}, @{$md5{$hash}} if (@{$md5{$hash}} > 1); } } return %dupes; } "dissolving ... removing ... there is water at the bottom of the ocean +";

In reply to Find Duplicate Files by salvadors

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others rifling through the Monastery: (7)
    As of 2020-11-25 22:30 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      No recent polls found

      Notices?