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

Reply via email to