This sounds a bit like an XY problem...
The best way to clean up a mess is to not make one in the first place
Why not simply trim the whitespace while you are first building the hash?
In reply to Re: Delete space at the end of a hash element
by SuicideJunkie
in thread Delete space at the end of a hash element
by Dr Manhattan
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |