| 1 | ## print all unrecognized lines in an EverQuest log file | ||
| 2 | |||
| 3 | use strict; | ||
| 4 | use warnings; | ||
| 5 | |||
| 6 | use Getopt::Std; | ||
| 7 | |||
| 8 | our ($opt_s); | ||
| 9 | |||
| 10 | getopts('s'); | ||
| 11 | |||
| 12 | my ($rec_count, $total_count) = (0,0); | ||
| 13 | |||
| 14 | use Games::EverQuest::LogLineParser; | ||
| 15 | |||
| 16 | die "USAGE: perl eqlog_unrecognized_lines.pl <eqlog_file> [output_file]\n" unless @ARGV > 0; | ||
| 17 | |||
| 18 | my ($eqlog_file, $output_file) = @ARGV; | ||
| 19 | |||
| 20 | $output_file = defined $output_file ? $output_file : '-'; | ||
| 21 | |||
| 22 | open (my $eqlog_fh, $eqlog_file) || die "$eqlog_file: $!"; | ||
| 23 | open (my $output_fh, ">$output_file") || die "$output_file: $!"; | ||
| 24 | |||
| 25 | my $start = time(); | ||
| 26 | |||
| 27 | while (<$eqlog_fh>) | ||
| 28 | { | ||
| 29 | |||
| 30 | $total_count++; | ||
| 31 | |||
| 32 | if (parse_eq_line($_)) | ||
| 33 | { | ||
| 34 | $rec_count++; | ||
| 35 | } | ||
| 36 | else | ||
| 37 | { | ||
| 38 | print $output_fh $_; | ||
| 39 | } | ||
| 40 | |||
| 41 | } | ||
| 42 | |||
| 43 | my $total_secs = time() - $start;; | ||
| 44 | |||
| 45 | if ($opt_s) | ||
| 46 | { | ||
| 47 | my $rec_percent = 100 * $rec_count / $total_count; | ||
| 48 | printf STDERR " %% recognized: %.01f ($rec_count/$total_count)\n", $rec_percent; | ||
| 49 | printf STDERR "lines per second: %d ($total_count/$total_secs)\n", $total_count / $total_secs; | ||
| 50 | } | ||
| 51 | |||
| 52 | close $eqlog_fh; | ||
| 53 | close $output_fh; | ||
| 54 | |||
| 55 | __END__ |