The stupid question is the question not asked | |
PerlMonks |
Re: I think regex Should Help Here... but How!?by ozboomer (Friar) |
on Feb 15, 2014 at 23:21 UTC ( [id://1075066]=note: print w/replies, xml ) | Need Help?? |
Many thanks for the postings, folks.. and profuse apologies for the somewhat vague requirements -- I really shouldn't try to be overly creative at (what is for me) such a late hour...! Maybe things would be clearer if step back some and explain the original issue... I have some records where one of the fields is a category, of sorts. It can be a simple, single item ('comp') or it can be a composite ('muse.new'). I start doing my processing by running though the complete set of records (in the 100s of 100+ character records, so not large), noting the record category in a hash (and storing other data besides). As a by-product, I might note that category strings can range from 1 to, say, 3 dot-delimited elements; for example, the formats of the categories might match one of 'aaa' (no dots), 'bbbb.cc' (one dot) and 'dd.eeee.f' (two dots). Now, let's define a 'level' as the number of 'words' in the category (as determined by the dot delimiters). So, a 'Level 1' category would include 'comp' and 'muse' but would NOT include '' (null) nor 'comp.hw'. Similarly, a 'Level 2' category would include 'comp.hw' and 'muse.new' but would NOT include 'garden.hw.new' nor 'magic.ancient.toys.tin'. ...and so it goes through all the 'levels' that I'd found in my initial pass through all the data records. So, in some sort of pseudocode, we might progress like:-
Thus, we'd end up with an output that is something like: At Level 1: comp = 100 (includes comp, comp.hw, comp.sw...) muse = 200 (inlcudes muse, muse.new, ...) At Level 2: comp.hw = 100 (includes comp.hw, NOT comp...) comp.sw = 200 (includes comp.sw, comp.sw.old, comp.sw.new...) ... Does that make things clearer?
In Section
Seekers of Perl Wisdom
|
|