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


in reply to trim leading & trailing whitespace

If you want to trim the leading and trailing whitespace from every line in a multiline string, you can use

s/^\s*(.*?)\s*$/$1/gm

cheers

thinker

Replies are listed 'Best First'.
Re^2: trim leading & trailing whitespace
by ady (Deacon) on Mar 30, 2005 at 08:47 UTC
    yup, i may need that, Good to have on the shelf! Thanks, Allan