title: perl + how to use chomp in foreach loop
body: <p>the following perl script (Showing down)</p>
  
  <p>print the following XML file
  but the XML have problem because the unnecessary "&amp;#10" char after TEST word</p>
  
  <pre><code> &lt;ROOT&gt;
       &lt;FILE Name="TEST1&amp;#10;"/&gt;
       &lt;FILE Name="TEST2&amp;#10;"/&gt;
       &lt;FILE Name="TEST&amp;#10;"/&gt;ar
  &lt;/ROOT&gt;
  </code></pre>
  
  <p>I think the "&amp;#10" characters its because the linebreak (read the output of a command into @myNames with the backtick operator)
  it seems that this problem of existing "&amp;#10" in my XML can be solved chomp command</p>
  
  <p>my question: in which way need to add the chomp command in my script in order to solve the problem</p>
  
  <p>my perl script</p>
  
  <pre><code>#!/usr/bin/perl
  
  use warnings;
  use XML::LibXML;
  
  
  my $doc  = XML::LibXML::Document-&gt;new; 
  my $root = $doc-&gt;createElement('ROOT');
  $doc-&gt;setDocumentElement($root);
  
  
  my @myNames=` ls /var/tmp | grep FILE.xml | sed "s/.FILE.*//"  `;
  
  foreach (@myNames) {
  
  my $objVar = $doc-&gt;createElement('FILE');
  $root-&gt;appendChild($objVar);
  $objVar-&gt;setAttribute('Name' , $_ );
  
  } 
  
  
  my @lines = split /\n/, $doc-&gt;toString(1);
  shift @lines;
  
  foreach (@lines) {
  
  print "$_\n";
  }
  </code></pre>
  
  <p>the files under /var/tmp</p>
  
  <pre><code>   TEST1-FILE.xml
     TEST2-FILE.xml
     TEST-FILE.xml
  </code></pre>