open( RTR, "$rtrlist" ) || die "Can't open $rtrlist file"; ... open( LOG, ">$workingdir/RESULT.TXT" )|| die "Can't open $workingdir/R +ESULT.TXT file"; ... $rtr = `$snmpget .1.3.6.1.4.1.9.2.1.3.0 $snmpro[0] $rtr` or print "hos +tname failed: $!\n"; ... $rtr = `$snmpget .1.3.6.1.4.1.9.2.1.3.0 $snmpro[1] $rtr` or print +"Host not responding to $snmpro[1]\n";
Consistency is always good. You should stick with either ( ... ) || ... or ... or ...
The use of $! with backticks is wrong. You SHOULD be using $! to indicate errors from open and $? to indicate errors from backticks.
printf " Router\t\t Location\t\t\tContact\t\t Serial\n"; printf LOG " Router\t\t; Location\t\t\t;Contact\t\t ;Serial\n";
You are using printf when you should be using print.
foreach (<RTR>) { chomp( $rtr = "$_" );
foreach needs to read the entire file into memory first before it can loop through the lines. The usual, more efficient method is to use a while loop if you only need one line at a time.
Why are you copying the value in $_ to a string when it is already a string?
In reply to Re: Looping through numerous snmp strings....
by jwkrahn
in thread Looping through numerous snmp strings....
by timmytimay
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |