#!/usr/local/bin/perl
if(!defined($ARGV[1])){print "specify a file\n";exit;}
open(FILE,$ARGV[0]) || die "Couldn't open: $!";
$begintime = time;
$no =0;
while(<FILE>){
  chop $_;
  $query = ''; 
  print $_,"\n";
  $_ =~ /^.*\](.*)$/; $key = $1;
  $_ =~ s/.*\[//g;
  $_ =~ s/\].*//g;
  
  foreach $i (split(':',$_)){
    if($i =~ /^V/){ next; } 
    $i =~ s/^(.)=/ -$1/g;
    $i =~ s/^(.)$/ -$1/g;
    $query .= $i;
    }  
  $query .= $key; 
  print "\$query = $query\n";
  $now1 = time;
  system(  "/space/dbdev/ottrey/whois_client/whois -h rowan -p $ARGV[1] $query") if($query !~ /^\s*$/);
  $now2 = time;
  $no++;
  print "Processed query in ", $now2-$now1, " seconds.\n";
  print "Total of $no queries in ", $now2-$begintime, " seconds. (", $no/($now2-$begintime), " queries per sec)\n" if (($now2-$begintime) != 0);
  print "\n";
}
$endtime = time;
print "Time in secs = ",$endtime - $begintime,"\n";
print "Total $no queries\n";
