3 # convert a DXSpider Log file to csv format
5 # usage: log2csv.pl <filename> ...
7 # Copyright (c) 2005 Dirk Koopman G1TLH
11 # make sure that modules are searched in the order local then perl
15 # root of directory tree for this system
16 use vars qw($root $is_win);
18 $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'};
20 unshift @INC, "$root/perl"; # this IS the right way round!
21 unshift @INC, "$root/local";
23 $is_win = ($^O =~ /^MS/ || $^O =~ /^OS-2/) ? 1 : 0; # is it Windows?
28 die "usage: log2csv.pl <filename> ....\n" unless @ARGV;
30 my $crnl = $is_win ? "\015\012" : "\012";
33 unless (open IN, $_) {
34 print STDERR "cannot open $_ $!\n";
39 s/([\%\"\'\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg;
40 my @line = split '\^';
41 my $date = unpad cldate($line[0]);
42 my $time = unpad ztime($line[0], 1);
43 print "$date\t$time\t$line[1]";
49 print "\t", join("\t", @line), $crnl;