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

use lib and locations in a variable

Thread Next
From:
Joseph Brenner
Date:
July 10, 2021 23:11
Subject:
use lib and locations in a variable
Message ID:
CAFfgvXU5yK6wAqrQ+xyfxMton-mN9Q4=kNAfk8P-79=Ws4a+DA@mail.gmail.com
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


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About