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

Re: use lib and locations in a variable

Thread Previous | Thread Next
ToddAndMargo via perl6-users
July 11, 2021 06:14
Re: use lib and locations in a variable
Message ID:
On 7/10/21 4:11 PM, Joseph Brenner wrote:
> 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.

Hi Joseph,

Okay, not what you asked. BUT WHEN DOES THAT STOP ME !!!
<maniacal laughter>

$*PROGRAM.parent is just a silly dot.  You an
hard code that yourself.

     $ p6 'print $*PROGRAM.parent ~ "\n";'

You can get the silly dot with curdir too

     $ p6 'print $*SPEC.curdir ~ "\n";'

If you want the full path, use `$*CWD.Str`:
     $ p6 'print $*CWD.Str ~ "\n";'

print does not need the .Str, but assigning it
to a string does.


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