On Sun, Jun 07, 2020 at 11:37:43AM +0200, JJ Merelo wrote:
> El dom., 7 jun. 2020 a las 11:32, Peter Pentchev (<r...@ringlet.net>)
> escribió:
> 
> > 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  r...@ringlet.net r...@debian.org p...@storpool.com
> > PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
> > Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13
> >
> 
> Also, you can simply issue different -I arguments when you invoke the
> script; you can put that in a shell or whatever script
> 
> raku -Imy/lib script
> 
> for your own lib
> 
> raku -Iother/lib script
> 
> for other
> 
> (or Windows equivalent). No need to use Raku to change the path, actually.

True, true :)

"Wait, let's take a step back; what are you *really* trying to do?" is
something that my coworkers have learned to expect when they come to me
with a question :) Thanks for calling me out on the same thing here!

G'luck,
Peter

-- 
Peter Pentchev  r...@ringlet.net r...@debian.org p...@storpool.com
PGP key:        http://people.FreeBSD.org/~roam/roam.key.asc
Key fingerprint 2EE7 A7A5 17FC 124C F115  C354 651E EFB0 2527 DF13

Attachment: signature.asc
Description: PGP signature

Reply via email to