title: Eliminate non-visible characters perl
body: <p>I have a perl variable that is being read in from another script's STDOUT:</p>
  
  <pre><code>$var = `someScript.sh`
  print $var    &lt;---- Prints "somestring"
  </code></pre>
  
  <p>However, the variable contains more than "somestring".  There are 15 more characters on the front of the variable (special and not-special but hidden) that don't show when I print. </p>
  
  <pre><code>length($var)  &lt;--- Returns a number 10-15 larger than "somestring" has chars
  </code></pre>
  
  <p>I can eliminate the special characters like so:</p>
  
  <pre><code>$var =~ s/[^[:print:]]+//g
  </code></pre>
  
  <p>But it appears that there are also non-special characters that are revealed once the special characters have been removed:</p>
  
  <pre><code>print $var   &lt;---- Displays "0;&lt;hostname&gt;somestring" 
              (where &lt;hostname&gt; is the system hostname)
  </code></pre>
  
  <p>Is there a way to eliminate both the special characters AND the non-special characters that were being hidden?  I want to be able to use $var as the key of a hash, and then reference it by "somestring"</p>
  
  <pre><code>$hash{$var} = 123
  print $hash{'somestring'} 
  </code></pre>
  
  <p>Thoughts?</p>