in reply to Looking for a better way to get the number of lines in a file...

Several things about programming style spring to mind.

The first is that you are using global variables. A brush with strict.pm can help you avoid using them, which will lessen the chances that subroutines will interfere with each other.

The second is that Perl has interpolation so that you don't need to concatenate. It is simpler to write "FILE: $FILE\n" and most people will find it somewhat easier.

Thirdly from comprehension studies, people's comprehension of code is significantly improved when your indent is in the range 2-4. You are using 8 (full tab-stop) and that is going to make any complex logic substantially harder to follow.

And last but not least, ALL CAPS IS SHOUTING! Anyone who has been around on the net for a while will be used to that convention, and it makes your code very hard to read for any length of time. Yes, this is an "important irrelevancy", something that is important to be consistent on, but which choice you make is fundamentally irrelevant. However the connection between capitals and shouting is rather widely accepted.

Oh, and a final book recommendation. Code Complete by Steve McConnell is a good place to learn a lot about what makes up good (procedural) programming style. It is a classic. Read it.

  • Comment on Re (tilly) 1: Looking for a better way to get the number of lines in a file...
  • Download Code