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


In reply to Re: Better way to check reverse DNS entries by Abigail-II
in thread Better way to check reverse DNS entries by !unlike

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.