Why read the whole file into an array?
To prevent the file being read every time the function is called. Of course, it isn't strictly necessary, but it seemed appropriate here.
Why process each record twice?
If you mean why read each record in and then split them all, I felt it simplified the lookups. You could split a record once it's been matched instead, but this does it all up front. It still runs in order-n time, so unless the table is huge, it shouldn't be a big deal.
Why perform a numeric comparison?
Because the IDs appeared to be numeric. Is this somehow worse than using eq?
Why the following line? $|++ ;
Part of my emacs template for Perl files; it prevents output buffering. For more info, see perlvar or Suffering from Buffering.
If you've got reasons why these methods are poor, I'm all ears.
Those who know that they are profound strive for clarity. Those who
would like to seem profound to the crowd strive for obscurity.
--Friedrich Nietzsche
In reply to Re: Re: Re: Cannot read in multiple lines
by DamnDirtyApe
in thread Cannot read in multiple lines
by Angel
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |