3 # grep for expressions in various fields of the dx file
11 # initialise spots file
14 #print "reading in spot data ..";
16 #$count = Spot->init();
18 #print "done ($t secs)\n";
30 last if $expr =~ /^q/i;
34 print "doing field $field with /$expr/\n";
49 @spots = Spot::search($expr);
50 if ($spots[0] eq "error") {
54 foreach $ref (@spots) {
56 my $t = ztime($dx[2]);
57 my $d = cldate($dx[2]);
58 print "$dx[0] $dx[1] $d $t $dx[4] <$dx[3]>\n";
62 print "$count records found, $t secs\n";
67 my ($expr, $from, $to) = @_;
75 $expr =~ s/\$f(\d)/zzzref->[$1]/g; # swap the letter n for the correct field name
76 $expr =~ s/[\@\$\%\{\}]//g; # remove any other funny characters
77 $expr =~ s/\&\w+\(//g; # remove subroutine calls
78 $expr =~ s/eval//g; # remove eval words
79 $expr =~ s/zzzref/\$ref/g; # put back the $ref
81 print "expr = $expr\n";
83 # build up eval to execute
85 for (\$c = \$#spots; \$c >= 0; \$c--) {
92 my @today = Julian::unixtoj(time);
93 for ($i = 0; $i < 60; ++$i) {
94 my @now = Julian::sub(@today, $i);
96 my $fp = Spot->open(@now);
100 foreach $in (<$fh>) {
102 push @spots, [ split('\^', $in) ];
106 return ("error", $@) if $@;
119 next if $time - $dx[2] > (84600 * 60);
120 unshift @spots, [ @dx ];
127 foreach $ref (@spots) {
128 if ($$ref[$field] =~ /$expr/i) {
130 my $t = ztime($dx[2]);
131 my $d = cldate($dx[2]);
132 print "$dx[0] $dx[1] $d $t $dx[4] <$dx[3]>\n";