note
GrandFather
<p>As others have suggested: Always use strictures (use [doc://strict]; use [doc://warnings]; - see [id://686571])!</p>
<p>You seem to be writing Perl circa 4.x rather than 5.x. There were many enhancements made to Perl between 4.x and 5.x with most of them improving robustness of code in various ways (using strictures is an example of that). A few things we do differently now:</p>
<ul>
<li>Use [doc://chomp] instead of [doc://chop]. chop simply removes the last character - whatever it was. chomp removes the a trailing copy of the contents of $/ (the input record separator special variable), normally a \n.</li>
<li>You don't need to initialise variables - Perl always does that by setting them to undef. </li>
<li>Don't call subs using &. That has a special meaning and will most often result in surprises - surprises are generally bad.</li>
<li>Don't use global variables. In small programs it's not such an issue, but as programs grow global variables make it very difficult to figure out how things work.</li>
</ul>
<div class="pmsig"><div class="pmsig-461912">
True laziness is hard work
</div></div>
862634
862634