bichonfrise74 has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl use strict; my %record = (); my ($title, $row); while (<>) { if (m/^\scustomer/i ... /rows\)/) { chomp; next if (/^\s+$/); next if (/^TEST/); next if (/---/); next if (/row/); if ($_ =~ m/\s(\D+)/i) { $title = $1; } if ($_ =~ m/\s+(\d+)/i) { $row = $1; } $record{$title} = $row if ( $title ne " "); } } map { print "$_ -> $record{$_}\n" } %record;
TEST HEADER CUSTOMERPHONE ----------- 1300 (1 row) TEST HEADER CUSTOMERORDER ----------- 0 (1 row) TEST HEADER CUSTOMERCARE ----------- 530 (1 row)
CUSTOMERORDER -> 1300 1300 -> -> 530 530 -> CUSTOMERPHONE -> -> CUSTOMERCARE -> 0 0 ->
CUSTOMERPHONE -> 1300 CUSTOMERORDER -> 0 CUSTOMERCARE -> 530
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Parsing a Simple Log File
by GrandFather (Saint) on Nov 05, 2008 at 00:21 UTC | |
by bichonfrise74 (Vicar) on Nov 05, 2008 at 00:39 UTC | |
by gone2015 (Deacon) on Nov 05, 2008 at 13:16 UTC | |
|
Re: Parsing a Simple Log File
by JavaFan (Canon) on Nov 04, 2008 at 23:56 UTC | |
|
Re: Parsing a Simple Log File
by monarch (Priest) on Nov 04, 2008 at 23:59 UTC | |
|
Re: Parsing a Simple Log File
by ccn (Vicar) on Nov 04, 2008 at 23:58 UTC |