in reply to parsing a file
Maybe I also expalin a little bit, but I didnt try out the code so there might be some bugs in it, I didnt notice. You create a hash of arrays with col as key and push each line that has no new col into the previous col. If there is a new col a new key and array is initiated and so on. I hope it is logical and helpfull.my %database; my $curCol; for(<DATASET>) { if(/^(col\d+)\s+(.*)/) #(.+) isnt good but as I dont know exactlly +how your data looks like... { push(@{$database{$1}}, $2); $curCol = $1; } elsif(/^\s+(.*)/) { push(@{$database{$curCol}}, $1); } }
|
|---|