http://qs1969.pair.com?node_id=46440


in reply to A looping and format question...

A large problem is that you seem to be assuming that:

Both are dangerous assumptions: I would definitely look at Net::Whois as mentioned above. It was made for this sort of thing.

Nonetheless, here is a quick fix of the code above. Not the best, but a little more readable.

#!/usr/bin/perl -w use strict; my ($DNS,$registrant,$admin,$tech,$billing,$domain_name,$expires); while (<>) { /^ ([\S]+)\s+[\d.]+/ and $DNS.="$1\n" and next; s/^\s+//; next unless length; m#Registrant:# .. m#\)# and chomp($registrant=$_) and ne +xt; m#Administrative Contact:# .. m#\)# and chomp($admin=$_) and ne +xt; m#Technical Contact:# .. m#\)# and chomp($tech=$_) and ne +xt; m#Billing Contact:# .. m#\)# and chomp($billing=$_) and ne +xt; /Domain Name:\s+([\w.]+)/ and $domain_name=$1 and next; /Record expires on\s+([^.]+)/ and $expires=$1 and next; } write STDOUT; format STDOUT = ====================================================================== +========== @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< $domain_name Registrant: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<< $registrant Admin: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<< $admin Tech: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<< $tech Billing: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<< $billing DNS: ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<< $DNS EXPIRES: @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< +<<<<<<< $expires .