Link to home
Start Free TrialLog in
Avatar of dfn48
dfn48

asked on

Edit Odbc.ini using perl module

I  am getting the following error in my program Global  symbol "$sections" requires explicit package name at insert_text.pl  line 17.
I don't know how to resolve this issue.

The program inserts EnableScrollableCursors=3  where each section in the odbc file matches the variables in the array.

See the attachment.  before_odbc.txt  is how the odbc.ini appears without EnableScrollableCursors=3. After_odbc.txt is results after the program inserts EnableScrollableCursors=3

Here is my code:
#!/usr/bin/perl

use strict;
use warnings;
use Config::IniFiles;

my $filename  = '/ss/scripts/odbc.txt';
my $cfg       = Config::IniFiles->new( -file => $filename  );
my @sections  = $cfg->sections;
my $parameter = 'EnableSrollableCursors';
my $value     = 3;
my @match     = qw(AMCSmartk_ AMCSmartfBC_  AMILX_  IHI_ETA_  ASO_  UHACSOI_);

foreach my $name (@match) {
    foreach my $section (@sections) {
        if ($section =~ /^$name/i) {
            $cfg->newval($section, $parameter, $value);
        }
    }
}
$cfg->RewriteConfig;

Open in new window

Before_odbc.txt
After_odbc.txt
ASKER CERTIFIED SOLUTION
Avatar of FishMonger
FishMonger
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of dfn48
dfn48

ASKER

Thanks