#---------------------------------------------------------------- # 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 array ref! $sql->errstr"; foreach my $rowref (@$host_array_ref) { my ($host) = @$rowref; print "Calling telenet stuff for $host\n"; #a little debugging output is fine # call your telenet routine on this host }