in reply to multi dimensional hash

best way to save all unique values of $tag1

You could add another level below variants

#!/usr/bin/perl use strict; use warnings; use Data::Dumper; my %hash; while (my $line = <DATA>){ my ($tag1, $tag2, $tag3) = split /\t/, $line; if ($tag2 =~/NN/) { ++$hash{$tag3}{frequency}; ++$hash{$tag3}{variants}{$tag1}; } } print Dumper \%hash;
poj