in reply to Strip leading and trailing blanks
Node How do I remove whitespace at the beginning or end of my string? is the Q&A's section answer to your problem. You'll find several ways to do it there.
If you're interested in an optimized version for trailing spaces (with discussion), try node Removing Trailing Whitespace: Multiple ways..
Michele.
In Section
Seekers of Perl Wisdom