Dr Manhattan has asked for the wisdom of the Perl Monks concerning the following question:
Hi all
I have a list of words in a hash. I want to delete all the spaces at the end of each element. The element should only consist of characters, no spaces at all.
foreach my $words (keys %hash) { if ($words =~ /( )*$/) { delete $1; } }
Or will this delete the entire element? Any help would be appreciated
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Delete space at the end of a hash element
by 2teez (Vicar) on Mar 26, 2013 at 09:25 UTC | |
by hdb (Monsignor) on Mar 26, 2013 at 09:33 UTC | |
Re: Delete space at the end of a hash element
by kcott (Archbishop) on Mar 26, 2013 at 09:57 UTC | |
Re: Delete space at the end of a hash element
by SuicideJunkie (Vicar) on Mar 26, 2013 at 17:45 UTC | |
by Laurent_R (Canon) on Mar 26, 2013 at 21:51 UTC | |
Re: Delete space at the end of a hash element
by hdb (Monsignor) on Mar 26, 2013 at 08:21 UTC | |
Re: Delete space at the end of a hash element
by space_monk (Chaplain) on Mar 26, 2013 at 12:43 UTC | |
Re: Delete space at the end of a hash element
by vinoth.ree (Monsignor) on Mar 26, 2013 at 11:06 UTC |
Back to
Seekers of Perl Wisdom