foreach (keys %index) { delete $index{$_} if /$test.+/ }