http://www.perlmonks.org?node_id=1025501


in reply to Delete space at the end of a hash element

Update:

Oops!!! I have given script to remove white spaces from values of hash...

I want to delete all the spaces at the end of each element

use strict; use warnings; use Data::Dumper; my %var_h =(1 => " value", "2" => "two "); s/(\s+)$//g for values %var_h; print Dumper \%var_h;

The element should only consist of characters, no spaces at all.

use strict; use warnings; use Data::Dumper; my %var_h =(1 => " value", "2" => "two "); s/\s+//g for values %var_h; print Dumper \%var_h;

All is well