Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Better way to check reverse DNS entries

by Abigail-II (Bishop)
on Apr 22, 2003 at 13:07 UTC ( [id://252260]=note: print w/replies, xml ) Need Help??


in reply to Better way to check reverse DNS entries

It's only a small piece of code, and if it works for you, why bother? I find all questions of the form "can this be done 'better'", or "what is the 'best' module to use when doing X" awkward. It all depends on your definition of "best". Some people say "best" means, "fastest", or "uses the least memory". For both types, the answer would usually be "do it in C instead of Perl". If with best you mean "least amount of key strokes", you should direct your question to a mailinglist about golf.

All I can say is how I would code it. Whether that is "better" or not, I leave to you. Afterall, it's your code, you get to decide what is better.

#!/usr/bin/perl use strict; use warnings; use Net::DNS; my $res = Net::DNS::Resolver -> new; my $net = "81.86"; foreach my $c (0x00 .. 0xFF) { foreach my $d (0x00 .. 0xFF) { my $ip = "$net.$c.$d"; print $ip unless $res -> query ($ip => 'PTR') } } __END__

I used 0x00 .. 0xFF instead of 0 .. 255 purely for aesthetic values.

Abigail

Replies are listed 'Best First'.
Re: Re: Better way to check reverse DNS entries
by !unlike (Beadle) on Apr 22, 2003 at 13:25 UTC

    Thanks Abigail, et al,
    I suppose by "better" I mean different. I know I have a certain mentality when it come to writing code. It usually works well for me, but every now and again I have difficulties in solving a problem this way.

    The code submitted worked, but was a simple enough problem that solutions provided by others would hopefully help me see another way of thinking.

    Just looking to improve I guess.

    !unlike

    I write my Perl code like how I like my sex: fast and dirty. ;)

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://252260]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (5)
As of 2024-04-25 12:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found