Hello: gonna keep it brief, as I've gotta get back to work.
I wrote my own little "whois" program to iterate through a list of domains work wants me to confirm. Got the data w/out too much pain. Now, I've got to print a report. I've
got the format looking the way I want it, but I'm getting huge amounts of duplicates from the loop. Any help would be GREATLY appreciated.
Here's my code: (keep in mind I'm a neophyte, so it won't be pretty!!)
#!/usr/bin/perl -w
OUTER: while (<>){
s/^\s+//; # trim off whitespace...
next OUTER if /^$/; # ignore blank lines
chomp;
$registrant=$_ if (/Registrant:/../\)/);
$domain_name=$_ if /Domain Name.*/;
$admin=$_ if /Administrative Contact:/../\)/;
$tech=$_ if /Technical Contact:/../\)/;
$billing=$_ if /Billing Contact:/../\)/;
$expires=$_ if /Record expires on .*/;
if (/NAME\..+\s+\d{1,3}.\d{1,3}.\d{1,3}/){
s/Name Server: .*//;
push @names, $_;
next OUTER;
}
write STDOUT if defined($registrant and $admin and $tech and
+ $billing and $names[2] and $expires);
}
format STDOUT =
======================================================================
+==========
@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< Registrant: @<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<<<<<<
$domain_name , $registrant
Admin: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<
$admin
Tech: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<
$tech
Billing: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<
$billing
DNS: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<
$names[0] @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<<<<<<<
$names[1] @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<
$names[2]@<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
+<<<<<<<<<<
$expires
======================================================================
+==========
.
.... I know the DNS portion of the above code is formatted poorly for this post, but it does work. For example, if I were to put in the output from a whois on "perlmonks.org,"
I'd end up with 18 or so duplicate reports. Any ideas? I'm sure it's a simple fix, but I've been looking at it for so long my brain is fried.
Thanks,
Matt