Echoing previous post, you should "use strict;"

Do not use function prototypes. This turns out to be a bad idea although it looks familiar from other languages. There is reason for them, but this is not it.

Once you have done that, I could move the main loop part of the code to the front and put the subs at the end.
I recoded one sub for you.

#---------------------------------------------------------------- # Execute a command on a Zhone device - recoded***** #---------------------------------------------------------------- sub zhoneCommand { my ($command,$session) = @_; #<- look at this line for I/F my @output=$session->cmd(String => "$command", Errmode => 'return'); chomp @output; return(@output); } #-------------- I would use fetchall_arrayref for a small, simple result set like this +. You get a reference to an array of server_host's. Then just iterate over that array. #--------------------- # loop through the servers table to pull data for each server my $sql = $dbc->prepare("SELECT server_host FROM servers"); my $result = $sql->execute(); or die "Unable to execute sql: $sql->errstr"; my $host_array_ref = $result->fetchall_arrayref() or die "can't get a +rray ref! $sql->errstr"; foreach my $rowref (@$host_array_ref) { my ($host) = @$rowref; print "Calling telenet stuff for $host\n"; #a little debugging o +utput is fine # call your telenet routine on this host }

In reply to Re: For each loop through mysql db to run Net::Telnet command by Marshall
in thread For each loop through mysql db to run Net::Telnet command by jay83

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.