X-Git-Url: http://gb7djk.dxcluster.net/gitweb/gitweb.cgi?a=blobdiff_plain;f=perl%2Fgdx.pl;fp=perl%2Fgdx.pl;h=8f6f2065edd75b8395c581d8146ed1279a5ea77d;hb=6f566611af29f5c7af653abf8cec2760a0c25b6e;hp=0000000000000000000000000000000000000000;hpb=15c6f0c107d136f8366bca25e3dcb7d14f2ed24b;p=spider.git diff --git a/perl/gdx.pl b/perl/gdx.pl new file mode 100755 index 00000000..8f6f2065 --- /dev/null +++ b/perl/gdx.pl @@ -0,0 +1,81 @@ +# +# grep for expressions in various fields of the dx file +# + +use FileHandle; +use DXUtil; +use DXDebug; +use spot; + +# initialise spots file +$count = spot->init(); + +dbgadd('spot'); + +$field = $ARGV[0]; +$expr = $ARGV[1]; +$time = time; + +print "$count database records read in\n"; + +STDOUT->autoflush(1); + +#loada(); +for (;;) { + print "field: "; + $field = ; + last if $field =~ /^q/i; + print "expr: "; + $expr = ; + + chomp $field; + chomp $expr; + + print "doing field $field with /$expr/\n"; + +#a(); + b(); +} + +sub b +{ + my @spots; + my @dx; + my $ref; + my $count; + + @spots = spot->search($field, $expr); + + foreach $ref (@spots) { + @dx = @$ref; + my $t = ztime($dx[2]); + my $d = cldate($dx[2]); + print "$dx[0] $dx[1] $d $t $dx[4] <$dx[3]>\n"; + ++$count; + } + print "$count records found\n"; +} + +sub loada +{ + while () { + chomp; + my @dx = split /\^/; + next if $time - $dx[2] > (84600 * 60); + unshift @spots, [ @dx ]; + ++$count; + } +} + +sub a +{ + foreach $ref (@spots) { + if ($$ref[$field] =~ /$expr/i) { + my @dx = @$ref; + my $t = ztime($dx[2]); + my $d = cldate($dx[2]); + print "$dx[0] $dx[1] $d $t $dx[4] <$dx[3]>\n"; + } + } +} +