On Sun, Jun 07, 2020 at 12:28:36AM -0700, ToddAndMargo via perl6-users wrote: > Hi All, > > Is there a way to do an "if" on "use lib", so > I do not have to keep commenting these back and forth? > > # use lib 'C:/NtUtil', '.'; > use lib 'C:/NtUtil', '.', 'K:/NtUtil';
"use lib" is evaluated quite early in the program's execution, so to do
any interesting things with it, you will need to use a BEGIN phaser
(similar to what you might know as a BEGIN block in Perl):
=================================
#!/usr/bin/env raku
use v6.d;
my $path;
BEGIN {
$path = 'lib1'.IO.d ?? 'lib1' !! 'lib2';
}
use lib $path;
use Foo;
Foo.new.hello;
=================================
Hope that helps!
G'luck,
Peter
--
Peter Pentchev [email protected] [email protected] [email protected]
PGP key: http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115 C354 651E EFB0 2527 DF13
signature.asc
Description: PGP signature
