title: Using Perl to remove n characters from the end of multiple lines
body: <p>I want to remove n characters from each line using PERL.</p>
  
  <p>For example, I have the following input:</p>
  
  <p>catbathatxx   (length 11; 11%3=2 characters) (Remove 2 characters from this line)</p>
  
  <p>mansunsonx    (length 10; 10%3=1 character)  (Remove 1 character from this line)</p>
  
  <pre><code>#!/usr/bin/perl -w
  open FH, "input.txt";
  @array=&lt;FH&gt;;
  foreach $tmp(@array)
  {
  $b=length($tmp)%3;
  my $c=substr($tmp, 0, length($tmp)-$b);
  print "$c\n";
  }
  </code></pre>
  
  <p>I want to output the final string (after the characters have been removed).</p>
  
  <p>However, this program is not giving the correct result. Can you please guide me on what the mistake is?</p>
  
  <p>Thanks a lot. Please let me know if there are any doubts/clarifications.</p>