my %fileinfo; my %dupes; # for each file, recursing through directory tree foreach { # here $_ is each file name # if filename seen already if( exists $fileinfo{$_} ) { # then record in %dupes $dupes{$_} = 1; } @filedata = ( $fpath, $fsize, $fdate ); # but using real data # if fileinfo doesn't yet have an entry for this $_, # then assign an empty array ref # saved_info is now an array ref which is # also stored in $fileinfo{$_} $saved_info = $fileinfo{$_} ||= []; push @$saved_info,\@filedata; # No need to re-store it in the hash, because $fileinfo{$_} # and $saved_info both point to the same array }