in reply to Re: Strip spaces in hash
in thread Strip spaces in hash

You're unintentionally modifying the hash values before the assignment. True, it's harmless in this case, but I think it's a bad habit. You also have loads of useless options on your substitution.
%hash = map { my $s=$_; $s=~s/\s+//g; $s } %hash;

or

use List::MoreUtils qw( apply ); %hash = apply { s/\s+//g } %hash;

Replies are listed 'Best First'.
Re^3: Strip spaces in hash
by AnomalousMonk (Archbishop) on Dec 09, 2009 at 19:26 UTC
    ... unintentionally modifying the hash values before the assignment [is] harmless in this case, but I think it's a bad habit.

    The modification was certainly not unintentional (or unconsidered), but I take your point. I wish I had thought to include a cautionary note about this (in fact, I think I will right now!) when I was going on about key collision, as I wish I had thought to use the  apply function.

    ... loads of useless options on your substitution.

    I have adopted this and other regex-related BPs from Conway's PBP. I know many monks would disagree, but the arguments for these practices are compelling to me.