have you tried reversing the array and joining it with a "."?

On Mon, 14 Feb 2005 18:38:36 +0100, Mariano Cunietti <[EMAIL PROTECTED]> wrote:
> Hi,
> I'm writing a simple script to perform some periodical checks on dns
> blacklist, so I can be quickly informed when one of my mail servers gets
> blacklisted.
> What I want is a function to query in-addr.arpa DNS and return an IP
> address.
> I used Net::DNS::Resolver, but the output is too long, and I need
> something more easy to be parsed. In other words, I need only the ANSWER
> SECTION (which maybe an A resurce or a CNAME and A response).
> 
> Here's the code (it's a draft, don't blame me):
> 
> =================================
> #!/usr/bin/perl
> use strict;
> use warnings;
> 
> use Net::DNS;
> 
> my @servers = qw(
>                 219.147.99.89
>                 212.29.141.7
>                 212.29.130.207
>                 212.29.130.208
>                 212.29.129.3
>                 212.29.129.4
>                 212.29.141.3
>                 212.29.141.33
>                 212.29.141.34
>         );
> my @dnsbl = qw(
>                 dnsbl.njabl.org
>                 list.dsbl.org
>                 dnsbl.sorbs.net
>                 sbl.spamhaus.org
>                 opm.blitzed.org
>                 bl.spamcop.net
>                 dynablock.njabl.org
>                 rfc-ignorant.org
>                 blackholes.five-ten-sg.com
>                 cbl.abuseat.org
>         );
> 
> my $res = Net::DNS::Resolver->new;
> foreach my $server (@servers) {
>         my @octets =split(/\./,$server);
>         my $prep_server =
> $octets[3].".".$octets[2].".".$octets[1].".".$octets[0];
>         foreach my $blacklist (@dnsbl)  {
>                 my $inaddrarpa = "$prep_server.$blacklist";
>                 my $answer = $res->query("$inaddrarpa", 'A');
>                 next unless ($answer);
>                 $answer->print;
>                 }
>         }
> }
> 
> =================================
> 
> Questions:
> 1 - Is there a better module to performs easy DNS queries?
> 2 - Is there a function to invert items in an array? (IP octects must be
> inverted before submitting)
> 3 - Which is the best module to send the report directly from the
> script?
> TIA
> 
> Mariano
> 
> --
> -----------------------------
> Mariano Cunietti
> System Administrator
> Enter S.r.l.
> Via  Stefanardo da Vimercate, 28
> 20128 - Milano - Italy
> Tel.  +39 02 25514319
> Fax   +39 02 25514303
> [EMAIL PROTECTED]
> www.enter.it - www.enterpoint.it
> -----------------------------
> Gruppo Y2K - www.gruppoy2k.it
> 
> --
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> <http://learn.perl.org/> <http://learn.perl.org/first-response>
> 
>

-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to