title: Perl Removing New Line
body: <p>I cant seem to remove the new line from an output I get by executing a command on linux server and have tried several different ways</p>
  
  <p>heres my code <strong>1st try</strong></p>
  
  <pre><code>$location = `curl -m 5 -sI 216.58.219.206 | grep "Location:"`;
  chomp ($location);
  print "before\n";
  print "$location";
  print "after\n";
  </code></pre>
  
  <p>output, Doesnt work, it gets printed with a new line.</p>
  
  <pre><code>before
  Location: http://www.google.com/
  after
  </code></pre>
  
  <p><strong>2nd try</strong></p>
  
  <pre><code>$location = `curl -m 5 -sI 216.58.219.206 | grep "Location:"`;
  $location =~ s/\n//g;
  print "before\n";
  print "$location";
  print "after\n";
  </code></pre>
  
  <p>Output, still doesn't work.</p>
  
  <pre><code>before
  Location: http://www.google.com/
  after
  </code></pre>
  
  <p>Raw Shell output</p>
  
  <pre><code>[user@localhost dir]# curl -m 5 -sI 216.58.219.206 | grep "Location:"
  Location: http://www.google.com/
  [user@localhost dir]#
  </code></pre>
  
  <p>Doesnt work either, I still see a new line.
  Am I missing something?</p>