%hash = map { my $s=$_; $s=~s/\s+//g; $s } %hash; #### use List::MoreUtils qw( apply ); %hash = apply { s/\s+//g } %hash;