Hello,
I have created the following include file located at /kpi/bin/KPIDB.pl package KPIDB; %config; sub readDBConfigFile { my $dbConfigFileName = '/kpi/cfg/databases.cfg'; my $cfgf; my $db; my $found = 0; my $alias; my $user; my $fh = new FileHandle("$dbConfigFileName", "r"); if (!defined($fh)) { print "Error: Can't open $dbConfigFileName file for reading: $!\n" if ($debug); exit(1); } while ($_ = $fh->getline) { next if (/\s*#/); # skip comments next unless (/\S/); # skip empty lines chomp; if (/^\s*$hostName:/) { $found = 1; ($host, $db, $user, $alias) = split(/:/); if (exists($config{$host})) { if (exists($config{$host}{$db})) { print "Error: duplicate lines for $host/$db\n" if ($debug); } else { $config{$host}{$db}{user} = $user; $config{$host}{$db}{alias} = $alias; } } else { $config{$host}{$db}{user} = $user; $config{$host}{$db}{alias} = $alias; } } } $fh->close; return($found); } 1; The following is the main program using the include file above. The problem is that when I call the function ' readDBConfigFile' it seems that it is not executing the function and does not Print any error. When inserting the code in the package to the main program, it works well. What am I doing wrong? #!/usr/local/bin/perl5.8.5 use Getopt::Long; use Sys::Hostname; use FileHandle; require "/kpi/bin/KPIDB.pl"; my $SU = '/bin/su'; sub usage { print "Usage: $0 [-h] [-d]\n"; } sub parseCommandLine { my $retCode = GetOptions('h' => \$help, 'd' => \$debug); usage and exit(1) if (!$retCode); usage and exit(0) if ($help); } sub main { my $status; my $command; my $db; parseCommandLine; $status = readDBConfigFile; if ($status) { foreach $db (keys %{$config{$host}}) { $command = "$SU - $config{$host}{$db}{user} -c \"$config{$host}{$db}{alias}; sqlplus -s /[EMAIL PROTECTED] @/kpi/bin/KPI1010-DB_SORTS.sql\""; system($command); } } } main; --------------------------------------------------------------------------------------------------------------- orange mail - Connect to your e-mail anywhere with any handset http://www.orange.co.il/web/corporate/app/omailadviser/webform1.aspx --------------------------------------------------------------------------------------------------------------- This message contains information that may be confidential or privileged. If you are not the intended recipient, you may not use, copy or disclose to anyone any of the information in this message. If you have received this message and are not the intended recipient, kindly notify the sender and delete this message from your computer.