Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation
 
PerlMonks  

Re: File::Find duplicate question

by Loops (Curate)
on Oct 24, 2014 at 23:06 UTC ( [id://1104934]=note: print w/replies, xml ) Need Help??


in reply to File::Find duplicate question

Hi there. It makes sense to only compare files of the same size so that is why they are compared and output in that order, within each size the output is based on a traversal of a Perl hash, which is essentially random. In order to force all '/' Characters to '\' in the output names, you could change the check_file sub to:

sub check_file { (my $fn = $File::Find::name) =~ tr#/#\\#; -f && push @{$files{(stat(_))[7]}}, $fn; }

Replies are listed 'Best First'.
Re^2: File::Find duplicate question
by Anonymous Monk on Oct 25, 2014 at 13:18 UTC
    Thanks for replying, It must just be my logic - I really thought that you'd check the name first of files, store them in the array then find duplicate names and then MD5 them to see if they are indeed the same. Thanks for the little piece of code.
    (my $fn = $File::Find::name) =~ tr#/#\\#;
    I have a few scripts using File::Find this is handy.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://1104934]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others having an uproarious good time at the Monastery: (7)
As of 2024-04-24 11:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found