title: Perl Regular expression remove double tabs, line breaks, white spaces
body: <p>I want to write a perl script that removes double tabs, line breaks and white spaces.</p>
  
  <p>What I have so far is:</p>
  
  <pre><code>$txt=~s/\r//gs;
  $txt=~s/ +/ /gs;
  $txt=~s/\t+/\t/gs;
  $txt=~s/[\t\n]*\n/\n/gs;
  $txt=~s/\n+/\n/gs;
  </code></pre>
  
  <p>But,
  1. It's not beautiful. Should be possible to do that with far less regexps.
  2. It just doesn't work and I really do not know why. It leaves some double tabs, white spaces and empty lines (i.e. lines with only a tab or whitespace)</p>
  
  <p>I could solve it with a while, but that is very slow and ugly.</p>
  
  <p>Any suggestions?</p>