my %files; foreach my $file_found (readdir(DIR)) { # next if $file_found =~ /^\.{1,2}\z/; my $size = (stat("$dir/$file_found"))[7]; $files{$size} ||= []; push @{ $files{$size} }, $file_found; } foreach my $same_size (values %files) { next if @$same_size == 1; print join(', ', @$same_size); }