We have a script that does a chunk of processing and populates the results in a hash. The hash is then used for more processing in a few places, some of which are expensive.
I wanted to be able to test the expensive bits of code with a smaller hash (taken from the real data), without having to touch each occurrence where the hash was used, so I figured modifying the hash in place would be acceptable, either by creating a temporary hash or deleting a hash slice.
Early experiments involved testing slices like (keys %hash)[5..-1], but didn't go very far. Will have to read up on array indexes and slices a bit more.
Thanks for the suggestions. Good to get a wider perspective on possible variations and solutions.
In reply to Re^2: Delete all hash keys except for n of them
by Anonymous Monk
in thread Delete all hash keys except for n of them
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |