my @data; foreach (keys %hash) { push @data, do_something_with($hash{$_}) if scalar @{$hash{$_}} > 0; }