Link to home
Start Free TrialLog in
Avatar of hexfusion
hexfusion

asked on

remove whitespace from hash_ref

I have hash is formatted like this
params => {test =>  ' 5 ' }

Open in new window


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;

Open in new window


#set the trim_filter
my $trim_filter = sub {
    return scalar($_[0] =~ s/^\s+|\s+$//g)
};

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of ozo
ozo
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of hexfusion
hexfusion

ASKER

Thanks as always ozo