Q:

make files to size zero if they have same checksum

i have an array with path of all files(C files) in it.
I am using Perl
@array
C:\temp\a.c
C:\temp\b.c
C:\temp\x.c
C:\temp\y.c
C:\temp\z.c

few files although have different file name might have same checksum(which means they have same content). these exist only in pairs. i have to make size of one of them as 0.
CODE
use File::Checksum;

my %array;
foreach my $k(@files3)
{                       
      $array{$k} = Checksum($k, 100);   
}

# have to check if they have same checksum and make those file to size 0

#making file size to 0 is easy. 
#I just have to open file in write mode and then close it.

need help in how to compare checksum of all files in an array and get filename for those with same checksum 

A:

Creating a hash "array" is confusing. Naming it "hash" is less confusing, but something like "unique" or "checksum" might work even better.
Use the checksum as the key, not the filename:
my %checksum;
for my $f (@files) {
    push @{ $checksum{ Checksum($f, 100) } }, $f;
}

The hash of arrays now contains all the files grouped by checksum. Delete the duplicates:
for my $ch (keys %checksum) {
    my @same = @{ $checksum{$ch} };
    if (@same == 2) {
        open my $FH, '>', $same[1] or die $!;
    } elsif (@same > 2) {
        warn "More than 2 files: @same. None deleted.\n";
    }
}

(Untested.)

