Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??
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":



  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others meditating upon the Monastery: (6)
As of 2024-04-23 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found