sub getConfig { my $file = shift(@_) ; my $function = ( caller(0) )[3] ; print "$function \n" ; # get the script .ini file my $script = basename($0); $script =~ s/\.\///; $script =~ s/pl$/ini/; my @files = ("env.ini", "config/$script") ; foreach my $file (@files) { unless ( -f $file ) { print "Could not find $file.\n" ; next ; } print "Config File : $file\n"; open(FH , "< $file"); my @array = ; close FH; my $group = 'default'; foreach my $line (@array) { chomp($line); next if ( $line =~ /^\s*\#/); if ($line =~ /^\[\w+\]$/){ $line =~ s/\[//g; $line =~ s/\]//g; $line =~ s/\s*//g; $group = $line; print "Found group : $group \n"; }else{ next unless ($line =~ /=/) ; my ( $key, $variable ) = split( /=/, $line, 2 ) ; $variable =~ s/\s+//g ; $key =~ s/\s+//g ; $ref->{$group}->{$key} = $variable; } } } return; }