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


in reply to How do I remove whitespace at the beginning or end of my string?

You could also do this in just one step. Use foreach's aliasing behavior to write this:
for ($string) { s/^\s+//; s/\s+$//; }