Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 18:49, ToddAndMargo via perl6-users wrote: ~ #!/usr/bin/env raku # Note: this has to be the first thing at the top my @LibPath; BEGIN { for ('K:/Windows/NtUtil', 'X:/NtUtil') -> $candidate { push @LibPath, $candidate if $candidate.IO.d; } push @LibPath, 'C:/NtUtil'; push @LibPath, '.'; } use lib @LibPath; dd @LibPath; dd $*REPO.repo-chain.lines; ~~ raku use.lib.test.pl6 Array @LibPath = ["K:/Windows/NtUtil", "C:/NtUtil", "."] ("K:\\Windows\\NtUtil C:\\NtUtil C:\\Users\\todd\\.raku C:\\rakudo\\share\\perl6\\site C:\\rakudo\\share\\perl6\\vendor C:\\rakudo\\share\\perl6\\core CompUnit::Repository::AbsolutePath<131860432> CompUnit::Repository::NQP<124427016> CompUnit::Repository::Perl5<124427056>",).Seq AH The above worked fine on my W10 virtual machine when called from Cobian, but on a customer's (native) Windows 10, I had to go back to using to comment out method.
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 00:28, 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'; Many thanks, -T Follow up: With tons of help from Peter and others, this is my keeper on "use lib": -T Perl 6: "use lib" delimiter: Single quote each path and separate with a comma: use lib '/usr/share/perl6/site/bin', '/home/linuxutil'; You can also feed it an array use lib @path To print you "use lib" path: $ raku -e 'use lib "/home/todd","/home/bozo"; say $*REPO.repo-chain;' (file#/home/bozo file#/home/todd inst#/home/todd/.raku inst#/opt/rakudo-pkg/share/perl6/site inst#/opt/rakudo-pkg/share/perl6/vendor inst#/opt/rakudo-pkg/share/perl6/core ap# nqp# perl5#) $ raku -e 'use lib "/home/todd","/home/bozo"; dd $*REPO.repo-chain;' (CompUnit::Repository::FileSystem.new(prefix => "/home/bozo"), CompUnit::Repository::FileSystem.new(prefix => "/home/todd"), CompUnit::Repository::Installation.new(prefix => "/home/todd/.raku"), CompUnit::Repository::Installation.new(prefix => "/opt/rakudo-pkg/share/perl6/site"), CompUnit::Repository::Installation.new(prefix => "/opt/rakudo-pkg/share/perl6/vendor"), CompUnit::Repository::Installation.new(prefix => "/opt/rakudo-pkg/share/perl6/core"), CompUnit::Repository::AbsolutePath.new(next-repo => CompUnit::Repository::NQP.new(next-repo => CompUnit::Repository::Perl5.new(next-repo => CompUnit::Repository))), CompUnit::Repository::NQP.new(next-repo => CompUnit::Repository::Perl5.new(next-repo => CompUnit::Repository)), CompUnit::Repository::Perl5.new(next-repo => CompUnit::Repository)) $ raku -e 'use lib "/home/todd","/home/bozo"; dd $*REPO.repo-chain.lines;' ("/home/bozo /home/todd /home/todd/.raku /opt/rakudo-pkg/share/perl6/site /opt/rakudo-pkg/share/perl6/vendor /opt/rakudo-pkg/share/perl6/core CompUnit::Repository::AbsolutePath<88733600> CompUnit::Repository::NQP<78635800> CompUnit::Repository::Perl5<78635840>",).Seq To add things to a "use lib" based on a test: ~ #!/usr/bin/env raku # Note: this has to be the first thing at the top my @LibPath; BEGIN { for ('K:/Windows/NtUtil', 'X:/NtUtil') -> $candidate { push @LibPath, $candidate if $candidate.IO.d; } push @LibPath, 'C:/NtUtil'; push @LibPath, '.'; } use lib @LibPath; dd @LibPath; dd $*REPO.repo-chain.lines; ~~ raku use.lib.test.pl6 Array @LibPath = ["K:/Windows/NtUtil", "C:/NtUtil", "."] ("K:\\Windows\\NtUtil C:\\NtUtil C:\\Users\\todd\\.raku C:\\rakudo\\share\\perl6\\site C:\\rakudo\\share\\perl6\\vendor C:\\rakudo\\share\\perl6\\core CompUnit::Repository::AbsolutePath<131860432> CompUnit::Repository::NQP<124427016> CompUnit::Repository::Perl5<124427056>",).Seq
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 14:40, Peter Pentchev wrote: On Mon, Jun 08, 2020 at 12:26:42AM +0300, Peter Pentchev wrote: On Mon, Jun 08, 2020 at 12:21:22AM +0300, Peter Pentchev wrote: On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users wrote: On 2020-06-07 13:53, Peter Pentchev wrote: $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; Got it! Thank you! I am not seeing the above enter the proper syntax: 'lib1', 'lib2' etc. Where is the comma? How are the single quotes entered? I don't understand what you are asking. The above checks whether a directory exists and, depending on the result of this check, assigns one of two values to a variable. I don't know what comma you are talking about. Wait, I think I got it. You're asking about the line underneath, the one that you did not quote in this message, the line that says: use lib $path; "use lib" expects you to pass a string (or more strings). 'c:/NtUtil' is a string. $path is a variable that holds a string. "use lib $path" calls "use lib" and passes to it the string in the variable $path. So to be a bit more clear, in your case you have a path that you always need to pass ('c:/something') and another one that you want to pass only if it exists. OK, so maybe something like: my @path; BEGIN { for ('K:/NtUtil', 'X:/NtUtil') -> $candidate { push @path, $candidate if $candidate.IO.d; } push @path, 'C:/NtUtil'; } use lib @path; Maybe something like that will work for you. G'luck, Peter Hi Peter, That worked. Thank you! Apparently I do not need the BEGIN. What was it's utility? ~ #!/usr/bin/env raku BEGIN { for ('K:/NtUtil', 'X:/NtUtil') -> $candidate { push @path, $candidate if $candidate.IO.d; } push @path, 'C:/NtUtil'; push @path, '.'; } use lib @path; dd @path; dd $*REPO.repo-chain.lines; ~~ raku use.lib.test.pl6 Array @path = ["K:/NtUtil", "C:/NtUtil", "."] ("K:\\Windows\\NtUtil C:\\NtUtil K:\\NtUtil C:\\Users\\tony\\.raku C:\\rakudo\\share\\perl6\\site C:\\rakudo\\share\\perl6\\vendor C:\\rakudo\\share\\perl6\\core CompUnit::Repository::AbsolutePath<127518976> CompUnit::Repository::NQP<126192040> CompUnit::Repository::Perl5<126192080>",).Seq -T
Re: Is thre a way to do an "if" on "use lib"?
On Sun, Jun 07, 2020 at 05:33:43PM -0400, Will Coleda wrote: > On Sun, Jun 7, 2020 at 4:53 PM Peter Pentchev wrote: > > > > On Sun, Jun 07, 2020 at 12:32:09PM -0700, ToddAndMargo via perl6-users > > wrote: > > > On 2020-06-07 02:32, Peter Pentchev wrote: > > > > > > > BEGIN { > > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > > > } > > > > > > Does the final "}" close the BEGIN? > > > > Well, there is an opening { after "BEGIN", so, yes. > > > > More precisely, it closes the block that is to be executed early. > > > > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > > > > > Hi Peter, > > > > > > Would you explain what the ?? and !! are > > > doing in the above? > > > > https://docs.raku.org/language/operators#infix_??_!! > > the URL with literal !! in it didn't work for me, but this does: > https://docs.raku.org/language/operators#infix_??_%21%21 Ah, but of course. Aren't Web standards and browsers great. I did copy and paste it from the location bar, and I did not stop to think about it, since I foolishly trusted that my browser would actually copy a usable URL. Thanks. 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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
On Mon, Jun 08, 2020 at 12:26:42AM +0300, Peter Pentchev wrote: > On Mon, Jun 08, 2020 at 12:21:22AM +0300, Peter Pentchev wrote: > > On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users > > wrote: > > > On 2020-06-07 13:53, Peter Pentchev wrote: > > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > > > > > Got it! Thank you! > > > > > > I am not seeing the above enter the proper syntax: > > > > > > 'lib1', 'lib2' etc. > > > > > > Where is the comma? How are the single quotes entered? > > > > I don't understand what you are asking. The above checks whether > > a directory exists and, depending on the result of this check, assigns > > one of two values to a variable. I don't know what comma you are talking > > about. > > Wait, I think I got it. You're asking about the line underneath, the one > that you did not quote in this message, the line that says: > > use lib $path; > > "use lib" expects you to pass a string (or more strings). 'c:/NtUtil' is > a string. $path is a variable that holds a string. "use lib $path" > calls "use lib" and passes to it the string in the variable $path. So to be a bit more clear, in your case you have a path that you always need to pass ('c:/something') and another one that you want to pass only if it exists. OK, so maybe something like: my @path; BEGIN { for ('K:/NtUtil', 'X:/NtUtil') -> $candidate { push @path, $candidate if $candidate.IO.d; } push @path, 'C:/NtUtil'; } use lib @path; Maybe something like that will work for you. 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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
the URL with literal !! in it didn't work for me, but this does: https://docs.raku.org/language/operators#infix_??_%21%21 On Sun, Jun 7, 2020 at 4:53 PM Peter Pentchev wrote: > > On Sun, Jun 07, 2020 at 12:32:09PM -0700, ToddAndMargo via perl6-users wrote: > > On 2020-06-07 02:32, Peter Pentchev wrote: > > > > > BEGIN { > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > > } > > > > Does the final "}" close the BEGIN? > > Well, there is an opening { after "BEGIN", so, yes. > > More precisely, it closes the block that is to be executed early. > > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > > > Hi Peter, > > > > Would you explain what the ?? and !! are > > doing in the above? > > https://docs.raku.org/language/operators#infix_??_!! > > 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
Re: Is thre a way to do an "if" on "use lib"?
On Mon, Jun 08, 2020 at 12:21:22AM +0300, Peter Pentchev wrote: > On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users wrote: > > On 2020-06-07 13:53, Peter Pentchev wrote: > > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > > > Got it! Thank you! > > > > I am not seeing the above enter the proper syntax: > > > > 'lib1', 'lib2' etc. > > > > Where is the comma? How are the single quotes entered? > > I don't understand what you are asking. The above checks whether > a directory exists and, depending on the result of this check, assigns > one of two values to a variable. I don't know what comma you are talking > about. Wait, I think I got it. You're asking about the line underneath, the one that you did not quote in this message, the line that says: use lib $path; "use lib" expects you to pass a string (or more strings). 'c:/NtUtil' is a string. $path is a variable that holds a string. "use lib $path" calls "use lib" and passes to it the string in the variable $path. 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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 12:32, ToddAndMargo via perl6-users wrote: n 2020-06-07 02:32, Peter Pentchev wrote: BEGIN { $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; } Does the final "}" close the BEGIN? Hi Peter, I am so use to BEGIN ... END In other languages, that I had to ask. Modula2 is especially a BEGIN and END user. I do adore the way Raku cleans up the unnesseary verbage. But I still do catch myself saying "DO" when I type "{" and "END" when I type "}" :'( -T
Re: Is thre a way to do an "if" on "use lib"?
On Sun, Jun 07, 2020 at 01:57:11PM -0700, ToddAndMargo via perl6-users wrote: > On 2020-06-07 13:53, Peter Pentchev wrote: > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > Got it! Thank you! > > I am not seeing the above enter the proper syntax: > > 'lib1', 'lib2' etc. > > Where is the comma? How are the single quotes entered? I don't understand what you are asking. The above checks whether a directory exists and, depending on the result of this check, assigns one of two values to a variable. I don't know what comma you are talking about. 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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 13:57, ToddAndMargo via perl6-users wrote: On 2020-06-07 13:53, Peter Pentchev wrote: $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; Got it! Thank you! I am not seeing the above enter the proper syntax: 'lib1', 'lib2' etc. Where is the comma? How are the single quotes entered? -T what am I doing wrong? ~~ #!/usr/bin/env raku my $path; BEGIN { # $path = 'K:/NtUtil'.IO.d ?? 'K:/NtUtil' !! 'C:/NtUtil'; # "" true; !! false $path = Q['] ~ 'X:/NtUtil'.IO.d ?? 'X:/NtUtil' !! ''; $path = Q['] ~ $path ~ Q[', 'C:/NtUtil', '.']; } use lib $path; print $path ~ "\n"; ~ K:\Windows\NtUtil>raku use.lib.test ===SORRY!=== Error while compiling K:\Windows\NtUtil/use.lib.test An exception occurred while evaluating a BEGIN at K:\Windows\NtUtil/use.lib.test:5 Exception details: Failed to find 'X:\NtUtil' while trying to do '.d' in block at use.lib.test line 7
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 13:53, Peter Pentchev wrote: $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; Got it! Thank you! I am not seeing the above enter the proper syntax: 'lib1', 'lib2' etc. Where is the comma? How are the single quotes entered? -T
Re: Is thre a way to do an "if" on "use lib"?
On Sun, Jun 07, 2020 at 12:32:09PM -0700, ToddAndMargo via perl6-users wrote: > On 2020-06-07 02:32, Peter Pentchev wrote: > > > BEGIN { > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > } > > Does the final "}" close the BEGIN? Well, there is an opening { after "BEGIN", so, yes. More precisely, it closes the block that is to be executed early. > > $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; > > Hi Peter, > > Would you explain what the ?? and !! are > doing in the above? https://docs.raku.org/language/operators#infix_??_!! 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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 02:32, Peter Pentchev wrote: BEGIN { $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; } Does the final "}" close the BEGIN? $path = 'lib1'.IO.d ?? 'lib1' !! 'lib2'; Hi Peter, Would you explain what the ?? and !! are doing in the above? Many thanks, -T
Re: Is thre a way to do an "if" on "use lib"?
On Sun, Jun 07, 2020 at 11:37:43AM +0200, JJ Merelo wrote: > El dom., 7 jun. 2020 a las 11:32, Peter Pentchev () > 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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
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. El dom., 7 jun. 2020 a las 11:32, Peter Pentchev () 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 > -- JJ
Re: Is thre a way to do an "if" on "use lib"?
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 signature.asc Description: PGP signature
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 01:39, JJ Merelo wrote: No, there's no else. This if is for using modules with different names. If you want to use modules in different paths, it's probably not a good idea to call them by the same name. You can call them different names (and do a use lib on all paths), or use other mechanisms to differentiate them, such as the :api module metadata Check everything about that here: https://docs.raku.org/language/typesystem#Versioning,_authorship,_and_API_version. My mock up has the modules in K:\NtUtil. My customer will have them in C:\NtUtil. K:\NtUtil is a Samba network drive so I can see only one copy of everything in all my Windows Virtual Machines. Can I have several "use lib" statements use lib 'C:\NtUtil", "."; use lib 'K:\NtUtil'; # if directory does not exist to use with the "if" statement?
Re: Is thre a way to do an "if" on "use lib"?
No, there's no else. This if is for using modules with different names. If you want to use modules in different paths, it's probably not a good idea to call them by the same name. You can call them different names (and do a use lib on all paths), or use other mechanisms to differentiate them, such as the :api module metadata Check everything about that here: https://docs.raku.org/language/typesystem#Versioning,_authorship,_and_API_version . El dom., 7 jun. 2020 a las 10:21, ToddAndMargo via perl6-users (< perl6-us...@perl.org>) escribió: > On 2020-06-07 00:55, ToddAndMargo via perl6-users wrote: > >>> El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users > >>> (mailto:perl6-us...@perl.org>>) escribió: > >>> > >>> 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'; > >>> > >>> Many thanks, > >>> -T > > > > On 2020-06-07 00:41, JJ Merelo wrote: > >> Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if > >> Install it with zef install if > >> > >> And then... > >> > >> > >> use if;# activate the :if adverb on use statements > >> > >> use My::Linux::Backend:if($*KERNEL.name eq 'linux'); > >> use My::Fallback::Backend:if($*KERNEL.name ne 'linux'); > > > > Hi JJ, > > > > Thank you! > > > > Would show me an example of how to use it > > with "use lib"? > > > > -T > > Also, is there an "else" that goes with that? > -- JJ
Re: Is thre a way to do an "if" on "use lib"?
On 2020-06-07 00:55, ToddAndMargo via perl6-users wrote: El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users (mailto:perl6-us...@perl.org>>) escribió: 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'; Many thanks, -T On 2020-06-07 00:41, JJ Merelo wrote: Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if Install it with zef install if And then... use if;# activate the :if adverb on use statements use My::Linux::Backend:if($*KERNEL.name eq 'linux'); use My::Fallback::Backend:if($*KERNEL.name ne 'linux'); Hi JJ, Thank you! Would show me an example of how to use it with "use lib"? -T Also, is there an "else" that goes with that?
Re: Is thre a way to do an "if" on "use lib"?
El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users (mailto:perl6-us...@perl.org>>) escribió: 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'; Many thanks, -T On 2020-06-07 00:41, JJ Merelo wrote: Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if Install it with zef install if And then... use if;# activate the :if adverb on use statements use My::Linux::Backend:if($*KERNEL.name eq 'linux'); use My::Fallback::Backend:if($*KERNEL.name ne 'linux'); Hi JJ, Thank you! Would show me an example of how to use it with "use lib"? -T
Re: Is thre a way to do an "if" on "use lib"?
Unsurprisingly, there is "if": https://github.com/FROGGS/p6-if Install it with zef install if And then... use if; # activate the :if adverb on use statements use My::Linux::Backend:if($*KERNEL.name eq 'linux');use My::Fallback::Backend:if($*KERNEL.name ne 'linux'); El dom., 7 jun. 2020 a las 9:29, ToddAndMargo via perl6-users (< perl6-us...@perl.org>) escribió: > 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'; > > Many thanks, > -T > -- JJ