On Wed, 11 Jul 2001, Hamish Whittal wrote:
> I have the following lines from a config file I am trying to read:
> {wellfleet ASN} .1.3.6.1.4.1.18.3
> (agentType) .1.3.6.1.4.1.18.3.3.1.11
> (chassisType) .1.3.6.1.4.1.18.3.1.1.1
>
> My code is:
> if ( $_ =~ /\{(.*)\}\s+(.*)/ ) {
> $dev = 1;
> $opt = lc($1);
> $opt =~ s/ //g;
> $value = $2;
> } elsif ( $_ =~ /\s*\((.*)\)\s+(.*)/ ) {
> $oid = 1;
> $opt = lc($1);
> $opt =~ s/ //g;
> $value = $2; #the OID of for this device
> } else {
> die ("Config file is badly built"); }
>
> The $1 works fine in the 1st if, but $2 will not return the .1.3.6.....
> Instead it return an empty string. Any clues.
Your $2 is getting wiped out by the $opt =~ s/ //g; line. BTW, I don't
know if you've looked at them or not, but there are a lot of SNMP modules
on CPAN, including a MIB compiler.
-- Brett
http://www.chapelperilous.net/btfwk/
------------------------------------------------------------------------
There are no rules for March. March is spring, sort of, usually, March
means maybe, but don't bet on it.