Just another Perl shrine | |
PerlMonks |
Re: best way to use grepby Laurent_R (Canon) |
on Dec 27, 2018 at 22:11 UTC ( [id://1227768]=note: print w/replies, xml ) | Need Help?? |
In terms of performance, the single most important change to be done is to use a hash enabling direct lookup instead of an array to store ther $xref data, as already suggested by Corion. Depending on the size of the $xref file, this change alone can make your program thousands times (or even much more) faster.
A few other changes might improve your code. Insert these pragmas: at the top of all your Perl programs, and declare your variables (with the my keyword). You don't need to store your customer file into an array (@lines) and then read the array, this leads you to process twice the same data, which is a waste of time. Do your checks when reading your customer file line by line; Use the three-argument syntax of open and use lexical file handles (see examples below). This could lead to something like this (untested): Update: removed some extra quote marks left out from the OP code when changing the open syntax. Thanks to choroba for pointing out.
In Section
Seekers of Perl Wisdom
|
|