Newbie here. Aplogies if I am missing details.
In perl 5
I have a file that kind of looks like this
precedence = 2
new york
new jersey
florida
precedence = 3
kings
essex
dade
precedence = 1
brooklyn
newark
miami
I have no problem looping through the file and creating a $var that holds the value of precedence and an array (@tmp) that holds the lines until the next "section" (precedence = x)
I need to ultimately push all the sections into a final array in the order of the preference
so
print @final;
results in
brooklyn
.....
new york
.....
kings
.....
NOTE: I never know in advance how many sections there will be or how many lines each section will have
I thought perhapes to make a Hash of hashes and put each array in the HoH
push @{ $hash{"section_2"} }, @tmp ;
but I didnt know
a) if there would be a problem reusing the @tmp array each time i load a section in (after blanking it at the beginning of each loop)
b) I couldnt figure out how to get all values in the array in key "section_2" and push them into @final
Of course there may be a better approach.