XP is just a number | |
PerlMonks |
Re: How to extract the best match from matrixby Marshall (Canon) |
on Mar 12, 2017 at 23:23 UTC ( [id://1184354]=note: print w/replies, xml ) | Need Help?? |
Hi jnarayan81, Yes, in general re-reading an input file multiple times is a bad idea. I/O is very "expensive" both in terms of CPU time, but also in terms of clock time. A simple way to read the input file once, could be: The above may or may not be the best data structure for your search requirements. But I suggest reading the input file only once. It appears to me that you are comparing columns. I think that you want an output that is based "best match(es)" for each each column. I added "africa4" above. What is supposed to happen if: my @array = (18,35,59,70); Should this first array value of 18 result in two matches in the first data column?, africa1 and africa4?? It is completely plausible that 16 and 20 are both equally close to 18. What should the output be in those cases?
In Section
Seekers of Perl Wisdom
|
|