To make the existing code work you need to skip the lines that don't have enough elements for the split to return for your comparisons:
while (<SNMP>) { next if /^#|^\s*$/; ...
or try this to use a regular expression instead;
while (<DATA>) { print "$1\n" if /^snmpmanager\s+(\d+\.\d+\.\d+\.\d+)\s+;\s+communi +tyname/; } __DATA__ #test file #example: snmpmanager 10.52.37.99 ; communityname public
In reply to Re: Need help with SNMP script
by Lotus1
in thread Need help with SNMP script
by Xandrex
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |