This seems reasonable enough to me, with the usual caveat that you will lose information if multiple elements share the same value.
I would never use this code in production, though. You mention other solutions using loops and map, but I find the %revhash = reverse %hash idiom more elegant.
In reply to Re: Swapping keys and values in a hash with slices
by tomhukins
in thread Swapping keys and values in a hash with slices
by pernod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |