#!/usr/pkg/bin/perl # $Id: pick-all-ja-result,v 1.3 2010/08/27 22:36:38 makoto Exp $ use strict; my $DEBUG = 0; sub split_entry($){ my $entry = shift; my $mode = ''; my $op = ''; my $band = ''; my $power = ''; if ($entry =~ /([CPX])(M{0,1})([0-9A]+)([PLMH])/ ) { $mode = $1; $op = $2; $band = $3; $power = $4; } if ($power) { return ($mode, $op, $band, $power);} else { die "Power code required for $entry.\n"; } } my ($result) = shift @ARGV; my ($entA, $callA, $entB, $callB, $entC, $callC) = @ARGV; print "$entA, $callA, $entB, $callB, $entC, $callC \n" if $DEBUG; my @entries = { qw( P35 P7 P14 P21 P28 P50 PA C35 C7 C14 C21 C28 C50 CA X35 X7 X14 X21 X28 X50 XA XMA XM2 XMJ XS )}; my @a = grep "$entA", @entries; print $#a, "\n" if $DEBUG; # --- read results --- my @results; open(RESULT, $result) || die "problem opening $result:$! \n"; @results = ; close (RESULT); my @PAIR_PTR; if ($callA) { push(@PAIR_PTR,[$entA, $callA]);} if ($callB) { push(@PAIR_PTR,[$entB, $callB]);} if ($callC) { push(@PAIR_PTR,[$entC, $callC]);} foreach my $i (@PAIR_PTR) { my ($ent) = $i->[0]; my ($call) = $i->[1]; print $ent, "\n"; print $call, "\n"; my ($mode, $op, $band, $power) = split_entry($ent); my (@read) = @results; my $search = $mode.$op.$band; print "$search++: $call\n" if $DEBUG; my $band_found = 0; my $call_done = 0; my $serial = 1; while ( $_ = shift @read) { if (/ $search$/) { $band_found++; print; } if ($band_found) { if (/$power$/) {printf "%2d %s", $serial++, $_} } if (/$call/) { $call_done++;} if ($band_found && $call_done) { last;} } } __END__