title: How can I add a newline after X number of characters in Perl?
body: <p>I was wondering how can I add a newline character (i.e. <code>/n</code> or <code>&lt;br&gt;</code>) after X number of characters. </p>
  
  <p>For example, let's say I have a perl variable $message ="aaaaabbbbbcccccdd". I want to add a newline character after every 5 characters to this variable. So when I print the variable in html it will display:</p>
  
  <pre><code>aaaaa 
  bbbbb 
  ccccc 
  dd    
  </code></pre>
  
  <p>What is the best way to do this? I was told to use substr or a count function, but I'm not sure how to go about it. Any help will be greatly appreciated. Thanks!</p>