pmonk has asked for the wisdom of the Perl Monks concerning the following question:

Hi- I heard about the 'perl monks' and had no where else to turn to. I have a whois script (from geektools) that takes a source ip and looks it up into several database registries to get information. The original script gets a standard input from the user but I need to give it a specific ip address. When I do this (192.32.13.45) it gives me 192.3213.45. The spacing is off somewhere but I can't find where. Can someone please help me! I need this script asap and I've been trying several things for quite a while now. The script is very long and I don 't want to post it here but here is the part where it splits the ip. If anyone wants to really help, I can send it to you personally via an attachment. Thanks so much monks!
####################################################### ## Configuration ## Location of TLD/Whois server list. my $RSList = "/export/home/manager/whois/whoislist"; ## Default whois server (don't undef this) $DefaultNic = "whois.networksolutions.com"; my $sip= 192.35.75.55; #print "IP ADDRESS: $QueryIn "; # my $QueryIn = <STDIN>; my $QueryIn = $sip; chomp $QueryIn; if ($QueryIn eq "") { &ShowResults(); exit 0; } my @QueryArray = split /\./, $QueryIn; my $QueryElements = @QueryArray; my $OrigQuery = $QueryIn; $QueryIn =~ tr/A-Z/a-z/; my @SuffixArray = split /\ /,$QueryIn; my $SuffixElements= @SuffixArray - 1; $SuffixArray[$SuffixElements] =~ tr/a-z.,0-9\-\+//cd; $QueryIn =~ tr/a-z.,0-9\-\@\!\ \+\:\///cd;

Edit: chipmunk 2001-08-27

Replies are listed 'Best First'.
Re: WHOIS help
by Maclir (Curate) on Aug 27, 2001 at 20:47 UTC
    Two initial suggestions that I would make are in the code fragment:
    my $sip= 192.35.75.55; #print "IP ADDRESS: $QueryIn "; # my $QueryIn = <STDIN>; my $QueryIn = $sip; chomp $QueryIn;
    I would put single quotes around your hard-coded ip address:
    my &sip = '192.35.75.55';
    This will force it to be a string, and hence later on when you are doing a string comparison (using Queryin eq ""), this should evaluate correctly.

    Also, since you are not reading this value from SYSIN, you do not need the chomp line. Now, while this in itself will not be causing a problem, it is probably safer.

    What does your sub ShowResults do?

      oh crap! It works!!! Damn- something so simple! Thanks so much!!! ShowResults does this:
      sub ShowResults { print "Query: $QueryIn\n"; print "Registry: $NicServ\n"; print "Results:\n"; if ($WhoisResults eq "") { $WhoisResults = "Null query, no data returned."; } print "$WhoisResults\n"; print "\n"; exit 0; }
      PMONK

      Edit kudra, 2001-08-28 Added code tags

Re: WHOIS help
by tomhukins (Curate) on Aug 27, 2001 at 19:43 UTC

    Is there any reason why you're not using Net::Whois for this?

    Several nodes on Perl Monks already discuss writing code to interface with whois. You can use Super Search to find them.

      I don't use NET::Whois because it searches whois information on the DNS not the source ip.