There is nothing in $2, because every time you do a RegExp, all of those
variables get initialized.

You do a $opt =~ s/ //g; before you request $2
do the $value = $2 before that line, and you will be fine.

-Akshay

Hamish Whittal wrote:
> 
> Hi All,
> 
> 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.
> 
> Thanks in advance.
> H
> 
> --
> Hamish Whittal          QED Technologies                Tel: +27 21 448 9291
> [EMAIL PROTECTED]                                      Fax: +27 21 448 9551
>                         `The' Linux Services Company    Cel: +27 82 803 5533

Reply via email to