Return Styles: Pseud0ch, Terminal, Valhalla, NES, Geocities, Blue Moon. Entire thread

Invalid Perl code

Name: Anonymous 2008-03-24 22:51

Oh man, it's 3:50 am and I have to stop working on this now. Posting its current state for your entertainment. Laugh at me if you want. Fix it if you want. I'll continue with it anyways.

#!/usr/bin/perl -w

if(@ARGV < 1){
        die "fd: This doesn't make too much sense now, does it...\n";
}

$relative_dir=$ARGV[0];

chomp(my @files = `ls -FA $ARGV[0]`);

foreach(@files){
        if(m/(.*)\*$/){
                $current_file = $1;
                next;
        } 
        elsif(m/[\/\@\|\=]$/){
                next;
        } 
        else{
                $current_file = $_;
        } 

        $current_file = $relative_dir . $_;
        chomp($sum = `md5sum $current_file | cut -d" " -f1`);
        #printf "%50s\t%s\n", $current_file, $sum;
        if(defined $md5sums{$sum}){
                print "$current_file seems to be a copy of $md5sums{$sum}\n";
        } 
        $md5sums{$sum} = $current_file;
}

Name: Anonymous 2008-03-25 2:52

>>3,4

#!/usr/bin/perl -w

use strict;

use Digest::MD5;
use File::Find;

my %files_by_size;
my %md5s;

map {find(sub {push @{$files_by_size{-s _}}, $File::Find::name if (-f $_ && -s _> 0 && $_ !~ m%[*/@|=~]$%); }, $_);} @ARGV;
map {map { if(open(TMP, $_)) { binmode(TMP); my $md5 = Digest::MD5->new->addfile(*TMP)->hexdigest; close(TMP); push @{$md5s{$md5}}, $_; }} @{$files_by_size{$_}} if $#{$files_by_size{$_}} >= 1} keys %files_by_size;
{ local $" = ",";print map {($#{$md5s{$_}} >= 1) ? "$_: @{$md5s{$_}}\n" : '' } keys %md5s; }


>>1
I think this is what you mean or were trying to do or something. 

Newer Posts
Don't change these.
Name: Email:
Entire Thread Thread List