laziness, impatience, and hubris | |
PerlMonks |
Re: How to delete trailing spaces from array elements?by radiantmatrix (Parson) |
on Jul 31, 2007 at 14:14 UTC ( [id://629837]=note: print w/replies, xml ) | Need Help?? |
There's a pretty common pattern for solving this, and it looks like this:
You'll commonly see the regular expression s/^\s+|\s+$//g as well -- which basically says "match any whitespace at the beginning or end of the string, and remove all of it". The shorter versions you see near the top of this discussion are simply shorter ways to write this pattern. In Perl, there's always more than one way to do things. To demonstrate that, here's another solution that would work (but I don't recommend):
Or, the shorter version:
<–radiant.matrix–>
Ramblings and references The Code that can be seen is not the true Code I haven't found a problem yet that can't be solved by a well-placed trebuchet
In Section
Seekers of Perl Wisdom
|
|