develooper Front page | perl.perl6.users | Postings from July 2021

use lib and locations in a variable

Thread Next
Joseph Brenner
July 10, 2021 23:11
use lib and locations in a variable
Message ID:
I want my test files to be able to find the modules they're testing
just using their relative locations, given the usual layout of "lib"
and "t" locations in parallel inside the project directory.

I find that while this works:

    use lib $*PROGRAM.parent.add('../lib');

This doesn't work:

    my $lib_loc = $*PROGRAM.parent.add('../lib');
    use lib "$lib_loc";

I get a compile time error

    Use of uninitialized value $lib_loc of type Any in string context.
    Repository specification can not be an empty string.  Did you mean
'use lib "."' ?

I thought that this would fix the problem, but I see the same
compile time error with it:

    BEGIN {
      my $lib_loc = $*PROGRAM.parent.add('../lib');
      use lib "$lib_loc";

Does that make sense to anyone?  It feels like a bug to me.

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About