la2.pl

  1. ############################
  2. # Written by Tomas ok4bx - www.bxhome.org
  3. # Script generate table with count of qso on every Mode/BAND from ADI log file.
  4. # Result format is suitable for TEXY parser (http://texy.info)
  5. #
  6. # You can use it and share this script for free,
  7. # only you must keep reference to my website in source and generated code!
  8. #
  9. $log_file = "log3.adi";
  10. @bands = qw/160m 80m 40m 30m 20m 17m 15m 12m 10m 6m 2m/;
  11. @modes = qw/ssb cw rtty psk31 psk63 qpsk31 qpsk63 hell fm/;  
  12.  
  13. $soubor=slurp($log_file);
  14. sub slurp {local$/=<>if local@ARGV=@_}
  15.  
  16. ############################
  17. # Skip ADI header
  18. $soubor =~ m%\<eoh\>(.*)%is;
  19. $soubor = $1;
  20.  
  21. ############################
  22. # Parse ADI file
  23. $qso=0;
  24. @adi_qso = split(/\<eor\>|\<EOR\>/,$soubor);
  25. foreach $record (@adi_qso) {
  26.   $qso++;
  27.   #if ($qso % 250 ==0) {print "#";}
  28.   while ( $record =~ m%^.*?<(.*?):(\d+).*?>(.*)$%si  ) {  
  29.     $k = lc($1);    
  30.     $l = $2;
  31.     $record = $3;
  32.     $v = substr($record,0,$l);    
  33.     $logbook[$qso]{$k}=$v;
  34.   }
  35. }
  36.  
  37. ############################
  38. # Count Statistic
  39. for $q (@logbook) {
  40.   $table { lc($q->{band}) }{ lc($q->{mode}) } ++;
  41. }        
  42.  
  43. ############################
  44. # Table Header
  45. print "| Mode |";
  46. foreach $b (@bands) {
  47.     printf" %4s |",$b;
  48.     $sep .= "-------";
  49. }
  50. print "      |\n|--------------".$sep."\n";  
  51.  
  52. ############################
  53. # Create table content
  54. $total=0;
  55. foreach $m (@modes) {
  56.     $total_mode = 0;  
  57.     printf "|%6s|", $m;
  58.     foreach $b (@bands) {        
  59.         printf "%5s |", $table{$b}{$m};
  60.         $total += $table{$b}{$m};
  61.         $total_mode += $table{$b}{$m};
  62.         $total_band{$b} += $table{$b}{$m}
  63.     }
  64.     printf "%5s |", $total_mode;
  65.     print "\n";
  66. }
  67.  
  68. #############################
  69. # Table Footer Sums
  70. print "|      |";
  71. foreach $b (@bands) {
  72.     printf "%5s |", $total_band{$b};
  73. }
  74. printf "%5s |", $total;
  75.  
  76. #############################
  77. # Bottom Info
  78. ($sec,$min,$hour,$mday,$mon,$year,$wday,$yday,$isdst)=localtime(time);
  79. print "\n\nCreated on ";
  80. printf "%2d/%02d/%04d",$mday,$mon+1,$year+1900;