foreach my $string ( @word ) { if ( $uword{ $string }[ 0 ] == 1 ) { push @{ $uword{ $string } }, $line; next; } $uword{ $string }[ 0 ] = 1; push @{ $uword{ $string } }, $line; } #this [0] is apparently not needed #maybe I'm missing something, but what do you think #that this does? #simplify to just... foreach my $string (@word) { push ( @{$uword{$string}}, $line ); }