title: Perl: insert a "\n" every 70 characters
body: <p>I have the following problem. I have a long string (1 thousand characters, more or less) and I am required to insert a "\n" every 70 characters. My idea was</p>
  
  <pre><code>my $finalstr;
      for($i=0; $i&lt;=length($input)+1; $i=$i+70){
      $finalstr.=$finalstr.substr($input,$i,3)."\n";
      }
  </code></pre>
  
  <p>But it doesn't seem to work.The problem is that I don't know how to use regex in this case because the number of characters in <code>$input</code> could be not a multiple of 70.</p>