#!/usr/bin/perl # # tlf2cab.pl - simple perl script to convert TLF log file to cabrillo log format # # use: $ cat | ./tlf2cab.pl > # # version 0.0.1 2012-01-15 - VE3GTC # - does no score computing # - to do: add simple help and make more universal to start with # #----------------------------------------------------------------------------------------------------- # # Cabrillo version 2.0 log format example (single op): # # START-OF-LOG: 2.0 # CALLSIGN: WA7BNM # CATEGORY: SINGLE-OP ALL LOW # CLAIMED-SCORE: 9 # CLUB: # CONTEST: NAQP-SSB # CREATED-BY: TR Log POST Version 6.67 # NAME: Bruce Horn # ADDRESS: 4225 Farmdale Avenue # ADDRESS: Studio City, CA 91604 # OPERATORS: WA7BNM # SOAPBOX: # QSO: 28300 PH 2003-01-18 1805 WA7BNM BRUCE CA XE2MX LOCO XE # QSO: 28300 PH 2003-01-18 1806 WA7BNM BRUCE CA NA4W CORT AL # QSO: 28300 PH 2003-01-18 1807 WA7BNM BRUCE CA W9RE MIKE IN # END-OF-LOG: # #--------------------------------------------------------------------------------------------------- # # TLF log format # # 10CW 14-Jan-12 18:42 0001 N7QQ 599 599 REX WA 1 # 10SSB 14-Jan-12 18:42 0001 N7QQ 599 599 REX WA 1 #--------------------------------------------------------------------------------------------------- # use strict; use warnings; use Switch; my $mode ; my $cabrilloRecord ; my $contest = "NAQP" ; my $myCall = "MYCALL" ; my $myName = "MYNAME" ; my $myQTH = "MYQTH" ; # # print out header for log - very simple at this point # print "START-OF-LOG: 2.0\n" ; print "CALLSIGN: MYCALL\n" ; print "CATEGORY: SINGLE-OP ALL QRP\n" ; print "CLAIMED-Score: \n" ; print "CLUB: MYCLUB\n" ; print "CONTEST: NAQP-CW\n" ; print "CREATED-BY: perl script tlf2cab v0.1\n" ; print "NAME: My Name\n" ; print "ADDRESS: MYADDRESS1\n" ; print "ADDRESS: MYADDRESS2\n" ; print "ADDRESS: MYADDRESS3\n" ; print "OPERATORS: MYCALL\n" ; print "SOAPBOX: \n" ; # # process input log file # while () { chomp; my ($band, $date, $time, $number, $Call, $sentRST, $rcvdRST, $Name, $QTH, $points) = split(' ', $_); # # reformat band and mode for cabrillo record # switch ($band) { case "10CW" { $band = "28000", $mode = "CW"; } case "10SSB" { $band = "28000", $mode = "PH"; } case "15CW" { $band = "21000", $mode = "CW"; } case "15SSB" { $band = "21000", $mode = "PH"; } case "20CW" { $band = "14000", $mode = "CW"; } case "20SSB" { $band = "14000", $mode = "PH"; } case "40CW" { $band = " 7000", $mode = "CW"; } case "40SSB" { $band = " 7000", $mode = "PH"; } case "80CW" { $band = " 3500", $mode = "CW"; } case "80SSB" { $band = " 3500", $mode = "PH"; } case "160CW" { $band = " 1800", $mode = "CW"; } case "160SSB" { $band = " 1800", $mode = "PH"; } else { $band = "unknown band or mode", $mode = "XX"; } } # # reformat date for cabrillo record # my ($day, $month, $year) = split('-', $date); switch (uc($month)) { case "JAN" { $month = "01"; } case "FEB" { $month = "02"; } case "MAR" { $month = "03"; } case "APR" { $month = "04"; } case "MAY" { $month = "05"; } case "JUN" { $month = "06"; } case "JUL" { $month = "07"; } case "AUG" { $month = "08"; } case "SEP" { $month = "09"; } case "OCT" { $month = "10"; } case "NOV" { $month = "11"; } case "DEC" { $month = "12"; } else { $month = "unknown month"; } } $date = "20".$year."-".$month."-".$day; # # formate time for cabrillo record # my ($hour, $minute) = split (':', $time); $time = $hour . $minute; # # put all the bits in their proper place and pad with spaces to the required field length # switch (uc($contest)) { case "NAQP" { # QSO Contents: # ----------info sent----------- ----------info rcvd----------- # QSO: freq mo date time call name qth call name qth t # QSO: ***** ** yyyy-mm-dd nnnn *************** aaaaaaaaaa aaa *************** aaaaaaaaaa aaa n # QSO: 14042 CW 1999-09-05 0000 N5TJ JEFF TX N6TR TREE OR # 000000000111111111122222222223333333333444444444455555555556666666666777777777788888888889999 # 123456789012345678901234567890123456789012345678901234567890123456789012345678901234567890123 # Example single-op QSO entries: # QSO: 3500 CW 2003-01-12 0541 WA7BNM BRUCE CA K6ZZ BOB CA # QSO: 14150 PH 2003-01-18 2120 WA7BNM BRUCE CA K6RO LARRY CA # QSO: 28050 RT 2003-02-22 1834 WA7BNM BRUCE CA K7WM WAYNE AZ # # Example multi-two QSO entries: # QSO: 28000 CW 2003-01-11 1803 N5TJ JEFF TX K6ZZ BOB CA 0 # QSO: 21000 CW 2003-01-11 1803 N5TJ JEFF TX WA7BNM BRUCE CA 1 # QSO: 21000 CW 2003-01-11 1804 N5TJ JEFF TX N6TR TREE OR 1 # # create cabrillo record # $cabrilloRecord = "QSO: "; $cabrilloRecord = $cabrilloRecord . $band . " " ; $cabrilloRecord = $cabrilloRecord . $mode . " " ; $cabrilloRecord = $cabrilloRecord . $date . " " ; $cabrilloRecord = $cabrilloRecord . $time . " " ; $cabrilloRecord = $cabrilloRecord . pack( 'A15', $myCall) . " " ; $cabrilloRecord = $cabrilloRecord . pack( 'A10', $myName) . " " ; $cabrilloRecord = $cabrilloRecord . pack( 'A3' , $myQTH) . " " ; $cabrilloRecord = $cabrilloRecord . pack( 'A15', $Call) . " " ; $cabrilloRecord = $cabrilloRecord . pack( 'A10', $Name) . " " ; $cabrilloRecord = $cabrilloRecord . pack( 'A3', $QTH) . " " ; } else { print "unknown contest \n"; } } print "$cabrilloRecord\n"; } print "END-OF-LOG:\n"; exit 0;