[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

Re: [MacPerl] Whois as BBEdit Perl Filter?



On 12:28 PM 5/12/00 "Brian McNett" <webmaster@mycoinfo.com> wrote:

> I'd like to adapt the sample whois client from the Perl Power Tools
> project for use as a BBEdit Perl Filter, but I've run into a bit of a
> problem or two.  I can figure out how to get the program to work as a
> stand-alone, but not as a filter.
> 
> Also the whois server returns text with Unix newlines, which need
> conversion.

I'm not even a perl guy :-)

One domain perl line.  Try this:

#!/usr/bin/perl -w

use IO::Socket;

$host = "whois.internic.net";

$| = 1;

while(<>)
{
    $sock = new IO::Socket::INET(PeerAddr => $host, 
                                 PeerPort => 43,
                                 Proto => 'tcp');

    die "IO::Socket::INET $!" unless $sock;

    chomp;
    print $sock "$_";
    
    print $sock "\x0A\x0D";

    while( defined($line = <$sock>) )
    {
        $line =~ tr/\x0A/\x0D/;
        chomp $line;
        print $line, "\n";
    }

    close($sock);
    
    print "\n\n";
}
}

-- 
Jim Correia                                Bare Bones Software, Inc.
correia@barebones.com                     <http://web.barebones.com>

# ===== Want to unsubscribe from this list?
# ===== Send mail with body "unsubscribe" to macperl-request@macperl.org