On Aug 7, Shimon Ravid said:

package KPIDB;

%config;

That's doing nothing.  Nothing at all.

sub readDBConfigFile {
...
}

1;

That function is defined in the KPIDB package; therefore, to call it from your main program, you'd have to call it as KPIDB::readDBConfigFile().

I haven't looked at your function body at all, though, so I won't comment on what your function does and how it might possible do a better job.

But your KPIDB.pl file should be using 'strict' and 'warnings'. It looks like you're declaring lexicals and all, so the only thing to change would be your "definition" of %config:

  package KPIDB;

  use strict;
  use warnings;

  our %config;

  ...

  1;

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.

If you had strict OR warnings turned on, you'd have a better idea why. It's generally a poor idea to call a function with no arguments AND omit its parentheses. Perl sees a "bareword" and doesn't always know if it's a function or not.

If you'd written it as readDBConfigFile(), you'd have gotten an error telling you that the function doesn't exist. That's because it's defined in a separate namespace. Do what I said above, and change

       $status = readDBConfigFile;

to

  $status = KPIDB::readDBConfigFile();

Now you have another problem, since that function populates the %config hash in the KPIDB package. To access it from main, you'll have to use $KPIDB::config{...} instead of $config{...}.

main;

Perl is not C. Please do not define a main() function and then call it as the body of your program. This is unnecessary.

--
Jeff "japhy" Pinyan         %  How can we ever be the sold short or
RPI Acacia Brother #734     %  the cheated, we who for every service
http://japhy.perlmonk.org/  %  have long ago been overpaid?
http://www.perlmonks.org/   %    -- Meister Eckhart

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>


Reply via email to