in reply to Re^3: use lib and use autouse 'module'
in thread use lib and use autouse 'module'

Thanks for your response. The directory name (only)is known at the beginning. The directory itself gets created (mounted) at a later time. So if this is the case, would the
use lib $g_moduleDir;
give a runtime error? When I tested this syntax in my perl script, It gave a message saying - Empty compile time value given to use lib. But then when I created the include directory, and called
require MY_MODULE;
it loaded the module and gave me access to all the functions and variables defined in the module. I noticed that this is not possible in autouse since we would have to specifiy all the functions and variables in the qw(). Appreciate your comments.

Replies are listed 'Best First'.
Re^5: use lib and use autouse 'module'
by Hue-Bond (Priest) on Jul 29, 2006 at 12:48 UTC
    would the use lib $g_moduleDir;give a runtime error?

    Didn't yesterday when I posted that, and didn't right now. This is what I tried:

    use lib '/home/hue/nonexistent'; use autouse 'FOO' => qw/foo/; sleep 10; foo;

    Then, in another console, did a mkdir nonexistent; mv FOO.pm nonexistent. No warnings or errors from the program, it just run seamlessly.

    Empty compile time value given to use lib

    It seems you passed an empty variable to lib. Check it.

    --
    David Serrano

      >> would the use lib $g_moduleDir;give a runtime error?

      Yes. use lib $g_moduleDir would need to be processed at RUNTIME after the $g_moduleDir variable has been set. Unfortunately "use" is processed at compile time and as such $g_moduleDir has not been set which will always create the empty string error that you have seen. You can hard code the path and it will work  use lib 'path/to/my/personal/lib/dir'

      *Update:

      Amusingly enough you can do something like this
      #!/usr/bin/perl BEGIN{ use Config::YAML; our $c= Config::YAML->new("/pathtoconfigfile"); our $inc_path = $c->get_includePath; } use lib $inc_path;