in reply to Allowed VLANs with SNMP
If I'm understanding you correctly (not entirely sure), you could use pack/unpack to convert your hex string "0xffff...fffe" into an ASCII "bit"-string, i.e. where each byte of the string is either the character "1" or "0". You would then simply use substr to test whether the char at a specific index is "1", which would mean the VLAN with that number/index is allowed. Something like this (simplified):
my $h = "ff00f0fe"; # just 32 bits here, but any other length possibl +e my $b = unpack("B*", pack("H*", $h)); print "$b\n"; # 11111111000000001111000011111110 my $idx = 5; my $allowed = substr($b, $idx-1, 1) eq "1";
Note that you need to remove the leading "0x" from the string.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Allowed VLANs with SNMP
by spivey49 (Monk) on Oct 23, 2008 at 19:17 UTC |