hexfusion
asked on
remove whitespace from hash_ref
I have hash is formatted like this
my goal is to strip any white space from the value of the test key. What I have is not working of course. How can I accomplish this in a 1 liner? Thanks
params => {test => ' 5 ' }
my goal is to strip any white space from the value of the test key. What I have is not working of course. How can I accomplish this in a 1 liner? Thanks
$params->{$trim_filter->{$_}} = delete $params->{$_} foreach keys %$params;
#set the trim_filter
my $trim_filter = sub {
return scalar($_[0] =~ s/^\s+|\s+$//g)
};
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER