X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fspot2csv.pl;h=53f5cec81b7b129e5ba5415f51ba2151c88e5863;hb=96c0247decddd941e8a191f48536d68506aca181;hp=100a8d3a2320be084fa61849808d66488a56163a;hpb=3298d47dabb1251d9906aca6b5158b405f29383f;p=spider.git diff --git a/perl/spot2csv.pl b/perl/spot2csv.pl index 100a8d3a..53f5cec8 100755 --- a/perl/spot2csv.pl +++ b/perl/spot2csv.pl @@ -6,16 +6,29 @@ # # Copyright (c) 2001 Dirk Koopman G1TLH # -# $Id$ +# # - # make sure that modules are searched in the order local then perl -use DXUtil; - use strict; +BEGIN { + # root of directory tree for this system + use vars qw($root $is_win); + $root = "/spider"; + $root = $ENV{'DXSPIDER_ROOT'} if $ENV{'DXSPIDER_ROOT'}; + + unshift @INC, "$root/perl"; # this IS the right way round! + unshift @INC, "$root/local"; + + $is_win = ($^O =~ /^MS/ || $^O =~ /^OS-2/) ? 1 : 0; # is it Windows? +} + +use DXUtil; + die "usage: spot2csv.pl ....\n" unless @ARGV; +my $crnl = $is_win ? "\015\012" : "\012"; + for (@ARGV) { unless (open IN, $_) { print STDERR "cannot open $_ $!\n"; @@ -25,11 +38,11 @@ for (@ARGV) { chomp; s/([\%\"\'\x00-\x1f\x7f-\xff])/sprintf("%%%02X", ord($1))/eg; my @spot = split '\^'; - my $date = cldate($spot[2]); - my $time = ztime($spot[2], 1); + my $date = unpad cldate($spot[2]); + my $time = unpad ztime($spot[2], 1); print "$spot[0]\t\"$spot[1]\"\t\"$date\"\t$time\t"; print $spot[3] ? "\"$spot[3]\"\t" : "\t"; - print "\"$spot[4]\"\t$spot[5]\t$spot[6]\t\"$spot[7]\"\r\n"; + print "\"$spot[4]\"\t$spot[5]\t$spot[6]\t\"$spot[7]\"$crnl"; } close IN; }