The stupid question is the question not asked | |
PerlMonks |
Adding hashes to already existing arrayby ExReg (Priest) |
on May 06, 2016 at 17:42 UTC ( [id://1162370]=perlquestion: print w/replies, xml ) | Need Help?? |
ExReg has asked for the wisdom of the Perl Monks concerning the following question: As a follow up to 1161099, I have an array of stuff that I have extracted from a big file via the use of regexes, call it @excerpts. Each array entry is then processed with regexes to get additional pieces of information. I would like to store those pieces of information in that same array, making a sort of array of hashes. In the example I gave, my file contents are $fc = 'abcdfoofrobnicatebardefforspambazghi';I get my @excerpts array filled with
I now have the @excerpts array
I now use the same $re2 regex to get
I would like to add these to the array, and make a sort of array of hashes. I would like to add {fpart} for $1 and {bpart} for $3 to each entry in @excerpts. The problem I have is that the only way I have found to do that is so ugly that I am afraid I will have bad Perl nightmares this weekend. The only way I have found to add or read the hash values is
They can be read back with the exact same expression. This construct just looks so unnatural that I am afraid it will invoke some unnatural activity from my PC when I have my back turned. None of the normal AoH notation worked in this case. Is there a better expression?
Back to
Seekers of Perl Wisdom
|
|