in reply to Any help for this problem. Parsing/constructing results

What you need is a matrix, as a data structure to store the mappings in. In Perl, this can be done easily with a hash of hashes.

Here's a code sample that should get you started: It reads in a single file from the DATA section, parses the mappings with a regular expression and stores them in a matrix.

The following for loops are iterating through the matrix, printing out the mappings.

Just repeat this for all of your files and add some code to produce a comma separated format, suitable for your spreadsheet program.

my $data = join '', <DATA>; my $matrix = {}; while($data =~ /"(\d+) \s+ \( (\w+)v(\w+) \)" /gx) { $matrix->{$2}->{$3} = $1; } for my $x (keys %$matrix) { for my $y (keys %{$matrix->{$x}}) { print "$x / $y => $matrix->{$x}->{$y}\n"; } } __DATA__ "S (00exp)", "2/16/105", "19:59:6", "131.111.249.177", "18 (04Age)", "M (05sex)", "british (07Cn)", " (17Com)", "8 (SvAA)", "9 (SvAE)", "10 (SvAH)", "10 (SvAO)", "9 (SvAW)", "10 (SvAY)", "5 (SvB)", "3 (SvCH +)", "4 (SvD)", "2 (SvDH)", "9 (SvEH)", "9 (SvER)", "8 (SvEY)", "2 (SvF)", "8 (SvG)", " (SvHH)", "2 (SvIH)", "9 (SvIY)", "3 (SvJH)", "5 (SvK)", "8 (SvL)", "7 (SvM)", "8 (SvN)", "9 (SvNG)", "10 (SvOW)", "9 (SvOY)", "4 (SvP)", "8 (SvR)", "2 (SvSH)", "8 (SvT)", "2 (SvTH)", "10 (SvUH)", "9 (SvUW)", "6 (SvV)", "7 (SvW)", "9 (SvY)", "4 (SvZ)", "6 (SvZH)", "complete"

Replies are listed 'Best First'.
Re^2: Any help for this problem. Parsing/constructing results
by Anonymous Monk on Feb 27, 2005 at 17:22 UTC
    is there a way i could get this to work if I just pasted the data from all (38) files, and also could it write to a file? Some of the files contain more than one set of the data, not sure if that makes a difference. - Thanks for the help! (steamerboy, not logged in)