#!/usr/bin/perl use warnings; use strict; my @files = get_files(); my %single_hash; for my $file (@files){ open my $fh, q{<}, $file or die qq{open to read $file failed: $!\n}; my $file_as_string = do{local $/;<$fh>}; push @{$single_hash{$file_as_string}}, $file; } for my $value (values %single_hash){ print qq{@{$value}\n}; } sub get_files{ # stuff return qw{one two three}; }