in reply to Re: removing redundantwhitespace
in thread removing redundantwhitespace

Ug, ignore the parent post. I missed the removal of blank lines and the removal of leading spaces. Here's the straightforward way, when reading from a file:
while (<$fh>) { chomp; s/^\s+//; next if !length; s/\s+$//; s/\s+/ /g; ... }

Replies are listed 'Best First'.
Re^3: removing redundantwhitespace
by Anonymous Monk on Sep 13, 2008 at 13:29 UTC
    Thanks, but I'm not actually reading from a file. I have this text in a single variable returned from a driver...
      for ($text) { s/^\s+//gm; s/\s+$//gm; s/(\s)\s+/$1/g; }