eqlog_line_type_frequency.pl untested

filter: Statementstmt 0.0% 0 / 34 Branchbran 0.0% 0 / 6 Conditioncond 0.0% 0 / 6 MC/DCmcdc 0.0% 0 / 3 Subroutinesub 0.0% 0 / 4 Podpod n/a totaltotal 0.0% 0 / 53 CC 1 SCAR 6.9
CC
1
Cov
0%
BEGIN
2.0
BEGIN
2.0
BEGIN
2.0
CRAP 2.0
1 ## report on the counts of line types in an EverQuest log file
2  
3 use strict;
4 use warnings;
5  
6 use Getopt::Std;
7  
8 our ($opt_n);
9  
10 getopts('n');
11  
12 use Games::EverQuest::LogLineParser;
13  
14 die "USAGE: perl eqlog_line_type_frequency.pl <eqlog_file> [output_file]\n" unless @ARGV > 0;
15  
16 my ($eqlog_file, $output_file) = @ARGV;
17  
18 $output_file = defined $output_file ? $output_file : '-';
19  
20 open (my $eqlog_fh, $eqlog_file) || die "$eqlog_file: $!";
21  
22 my %freq;
23  
24 while (<$eqlog_fh>)
25 {
26  
27 (my $line = parse_eq_line($_)) || next;
28  
29 $freq{ $line->{'line_type'} } ++;
30  
31 }
32  
33 close $eqlog_fh;
34  
35 open (my $output_fh, ">$output_file") || die "$output_file: $!";
36  
37 if ($opt_n)
38 {
39 for (sort { $freq{$a} <=> $freq{$b} } keys %freq)
40 {
41 printf $output_fh " %-24s => %s\n", $_, $freq{$_};
42 }
43 }
44 else
45 {
46 for (sort keys %freq)
47 {
48 printf $output_fh " %-24s => %s\n", $_, $freq{$_};
49 }
50 }
51  
52 close $output_fh;
53  
54 __END__