Last active
August 15, 2016 21:36
-
-
Save cowens/274db824f84de06f68b9822add603a98 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/perl | |
sub chomp { | |
$_[0] =~ s/[\r\n]+//; | |
} | |
sub get_time { | |
$label = shift; | |
local(@now); @now = localtime; | |
$now[5] += 1900; | |
$now[4]++; | |
local($time); $time = "bork"; | |
local($date); $date = "bork"; | |
while ($time !~ /^quit$|^[0-9]{4}$|^$/) { | |
print "$label time: "; | |
&chomp($time = <STDIN>); | |
} | |
if ($time eq "quit") { | |
dbmclose(%db); | |
exit; | |
} | |
if ($time eq "") { | |
$date = sprintf("%04d-%02d-%02d", @now[5,4,3]); | |
$time = sprintf("%02d%02d", @now[2,1]); | |
} else { | |
while ($date !~ /^[0-9]{4}-[0-9]{2}-[0-9]{2}$|^$/) { | |
print "$label date:"; | |
&chomp($date = <STDIN>); | |
} | |
if ($date eq "") { | |
$date = sprintf("%04d-%02d-%02d", @now[5,4,3]); | |
} | |
} | |
return $date, $time; | |
} | |
$| = 1; # turn off buffering | |
dbmopen(%db, "calllog", 0777); | |
while (1) { | |
($date, $time) = &get_time("start"); | |
print "mode: "; | |
&chomp($mode = <STDIN>); | |
if ($mode =~ /^c/i) { | |
$mode = "CW"; | |
} elsif ($mode =~ /^f/i) { | |
$mode = "FM"; | |
} elsif ($mode =~ /^r/i) { | |
$mode = "RY"; | |
} else { | |
$mode = "PH"; | |
} | |
$callsign = ""; | |
do { | |
print "callsign: "; | |
&chomp($callsign = <STDIN>); | |
$callsign =~ tr/a-z0-9\//A-Z0-9\//; | |
} until ($callsign =~ /[A-Z0-9\/]{3,13}/); | |
print "freq: "; | |
&chomp($freq = <STDIN>); | |
if ($db{"$date,$mode,$callsign,$freq"}) { | |
print "dup entry detected\n\n"; | |
next; | |
} | |
print "your exchange: "; | |
&chomp($your_exch = <STDIN>); | |
print "their exchange: "; | |
&chomp($their_exch = <STDIN>); | |
$record = join(",", | |
$freq, $mode, $date, $time, $your_exch, $callsign, $their_exch | |
); | |
print "saving record: $record\n\n"; | |
$db{"$date,$mode,$callsign,$freq"} = $record; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment