Your immediate problem has been solved, but here are a few other pointers that may help.
  1. #Trying to get default values working here -- still working on it

    Check out Getopt::Long - makes processing command line arguments a snap.

  2. You can save yourself a bit of typing, by doing:
    chomp($ipbase = <STDIN>);
    Instead of:
    $ipbase = <stdin>; chomp ($ipbase);

  3. #I would like to find a way to turn off echo or mask this portion print "Password:"; $password = <stdin>;
    There are several ways to do this - check out perlfaq8. (You'll probably want to use Term::ReadKey)

  4. It's always a good idea to check the return status of any filehandle operations (and a bad idea not to), because you never know what may have gone wrong outside your program. So..
    open(INFO,">$downreport");
    Is better written as:
    open INFO, '>', $downreport or die "Cannot open $downreport:$!\n";
    Note that any OS error will be returned as the contents of $!. Also note the use of open with three arguments, instead of two. This is generally accepted as a better (and safer) practice.
    Actually, even that is a bit outdated. These days perl allows you to use normal scalar variables as filehandle references. So you can do something like:
    open my $info, '>', $downreport or die "Cannot open $downreport:$!\n";
    See the docs on open for more information.

  5. One last point... anytime you find yourself repeating code, then thats a pretty good sign that you need to do a bit of abstraction, and break some of your code out into a subroutine. In your case, it's all the gathering of user input that you do via STDIN (Note that is is common practice to write STDIN, STDOUT and STDERR in all upper-case). So instead of:
    print "What is the base IP? (Example: 192.168.1)\n"; $ipbase = <stdin>; chomp ($ipbase); print "What is the bottom IP? (Default 1)\n"; $ipcurrent = <stdin>; chomp ($ipcurrent); print "What is the top IP? (Default 255)\n"; $ipend = <stdin>; chomp ($ipend); # etc....
    You could do something like:
    sub get_user_input { my $prompt = shift; print "$prompt\n"; return chomp(<STDIN>) }
    And then:
    $ipbase = get_user_input("What is the base IP? (Example: 192.168.1)"); $ipcurrent = get_user_input("What is the bottom IP? (Default 1)"); $ipend = get_user_input("What is the top IP? (Default 255)");
    There are further levels of abstraction that could be applied if you wanted to (a dispatch table, for example) - but I'm sure you get the idea ;)

Hope all the above helps,
Cheers,
Darren :)


In reply to Re: Login failure with net::Telnet by McDarren
in thread Login failure with net::Telnet by unixgeek

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.