Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
Re: Searching between two hashesby AnomalousMonk (Archbishop) |
on Nov 10, 2017 at 22:32 UTC ( [id://1203149]=note: print w/replies, xml ) | Need Help?? |
Quite apart from the main concern of your post, the comparison of hashes, another thing that comes to mind is that the sight of those serried ranks of lexical variables marching down the page makes my brain hurt. Not to go all sundialsvc4 on you, but this looks like a guaranteed, copper-bottomed MaintenanceNightmare™. One approach to this type of organizational problem is to define constant sets of tags. These tags, which can be, e.g., strings, can then be used as hash keys, header lines (when concatenated together), etc. A tag set never changes its order once defined. They can be used with hash slices to assign to and extract data from hashes as an ordered set. E.g.: Note that to disambiguate a constant list for use with a hash slice, the () (subroutine invocation) operator must be used (update: & could be used as well, e.g. &INPUT_TAGS (update: but see choroba's pertinent comment here)) to prevent Perl from interpreting something like INPUT_TAGS as a string. Another point is that rather than using a naive split, it's almost always better to use Text::CSV_XS or Text::CSV for extracting CSV-ish data. Update: Corrected small code example error. Give a man a fish: <%-{-{-{-<
In Section
Seekers of Perl Wisdom
|
|