in reply to Multiple conditions matching when pulling OID value with Net::SNMP
Very simply, you are doing an assignment rather than a test for equality.
Change
if ( $status = $on_commercial ) { print "The ups is normal\n"; } if ( my $status = $on_battery ) { print "The ups is on battery\n"; }
to:
if ( $status == $on_commercial ) { print "The ups is normal\n"; } if ( my $status == $on_battery ) { print "The ups is on battery\n"; }
... and you should be all set.
If you need to compare strings instead of values, use eq instead of ==.
|
|---|