foreach (@lines) { my ($key, $value) = munge($_); next unless defined $value; # Don't bother creating empty hash entries in the first place ;) push @{$hash{$key}}, $value; }