Basically what Chromatic and Gaal have already told you, but also:

use vars qw/ %opt /;

Why not just use sub-quotes instead? You're quoting a word, not words.

sub revlookup {

revlookup? What does that mean? I'm gonna take a guess and say "reverse lookup," but the only way I could determine that was to look at the routine code itself. I shouldn't have to do that. The name should tell me exactly what the routine does. Why not reverse_lookup() or--if you like CamelCase--reverseLookup() instead?

my $res=Net::DNS::Resolver->new; $res->nameservers($server); my $search = $res->search($input);

Inconsistency does terrible, terrible things to software. How come some of your assignment statements have spaces on either side of the equals sign but others don't?

if ($search) { foreach $rr ( $search->answer)

Again with the inconsistancy. Why the extra space around $search->answer but not $search? They're both conditionals, right?

sub fwlookup {

The name thing again: try forward_lookup() or forwardLookup() instead.

sub options { use Getopt::Long;

That use statement belongs towards the top of the script; it's a compile-time declaration and in this case sticking it inside of a routine doesn't change its behavior, it merely obfuscates it.

I would recommend giving perlstyle a good once-over. You don't have to take it as gospal, but at least consider each and every one of its recommendations and follow them unless you have good reason not to.


In reply to Re: code review by William G. Davis
in thread code review by svankalken

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.