On Aug 2, awarsd said:

>#!/usr/bin/perl
>
>use CGI qw(:standard);
>use DBI;
>
>require "/path/to/config.pl";
> ##inside config.pl it has $dataDir
>##$dataDir = "/path/to/";
>use lib $dataDir."Module";
>use Test;

You named your module "Test"?  That's why you're getting a false positive.
There's a standard module named Test; it's being use'd, instead of your
module.

The 'use lib ...' statement happens at COMPILE-time.  The 'require ...'
statement happens at RUN-time.  COMPILE-time is before RUN-time, so 'use
lib ...' happens first, and $datadir is EMPTY then, because it hasn't been
filled, because 'require ...' hasn't happened yet.

You must do two things:

1. rename your module, to something like MyStuff.pm
2. put the 'require ...' code inside a BEGIN block

  BEGIN { require "/path/to/config.pl" }
  use lib "$dataDir/Module";
  use MyStuff;

>Should I declare variable i.e
>my $datDir inside the program or in the config.pl??
>Also should i declare in module $main::dataDir like
>my $main::dataDir; or I can just leave $main::dataDir??

If you declare any my() variables in config.pl, NO OTHER FILE can see
them.  Therefore, do NOT make $dataDir a my() variable.  Furthermore, a
my() variable CANNOT belong to a package, so you can't say my $main::var.
It just doesn't make sense.

Leave your variables as they are.

-- 
Jeff "japhy" Pinyan      [EMAIL PROTECTED]      http://www.pobox.com/~japhy/
RPI Acacia brother #734   http://www.perlmonks.org/   http://www.cpan.org/
<stu> what does y/// stand for?  <tenderpuss> why, yansliterate of course.
[  I'm looking for programming work.  If you like my work, let me know.  ]



-- 
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to