Re: I need `dir` help

2018-05-10 Thread ToddAndMargo

On 05/10/2018 05:42 PM, Brad Gilbert wrote:

On Thu, May 10, 2018 at 7:02 PM, ToddAndMargo  wrote:

On 05/10/2018 04:56 PM, Brandon Allbery wrote:


I think you'll need to provide a better explanation of what you're trying
to accomplish. I can think of lots of ways to do useful things with the
output of dir(), but have no idea which one(s) you need.



I wanted to loop through entries as an exercise.  Although this
is not really necessary with `indir` as you can ask directly
if something is in a directory.



That's not what `indir` does

What it does is change the current working directory inside of a block

 put $*CWD; # /home/brad
 indir "/tmp", {
 put "in directory $*CWD"; # /tmp
 .put for dir()
 }
 put $*CWD; # /home/brad


Also this

 $ perl6 -e 'for dir() -> $x { my $y="$x"; say $y };'

can be simplified to any of:

 $ perl6 -e 'for dir() -> $x { say ~$x }'
 $ perl6 -e 'for dir() -> $x { put $x }'
 $ perl6 -e '.put for dir'



Thank you!


Re: I need `dir` help

2018-05-10 Thread Brad Gilbert
On Thu, May 10, 2018 at 7:02 PM, ToddAndMargo  wrote:
> On 05/10/2018 04:56 PM, Brandon Allbery wrote:
>>
>> I think you'll need to provide a better explanation of what you're trying
>> to accomplish. I can think of lots of ways to do useful things with the
>> output of dir(), but have no idea which one(s) you need.
>
>
> I wanted to loop through entries as an exercise.  Although this
> is not really necessary with `indir` as you can ask directly
> if something is in a directory.
>

That's not what `indir` does

What it does is change the current working directory inside of a block

put $*CWD; # /home/brad
indir "/tmp", {
put "in directory $*CWD"; # /tmp
.put for dir()
}
put $*CWD; # /home/brad


Also this

$ perl6 -e 'for dir() -> $x { my $y="$x"; say $y };'

can be simplified to any of:

$ perl6 -e 'for dir() -> $x { say ~$x }'
$ perl6 -e 'for dir() -> $x { put $x }'
$ perl6 -e '.put for dir'


Re: I need `dir` help

2018-05-10 Thread ToddAndMargo

On 05/10/2018 04:56 PM, Brandon Allbery wrote:
I think you'll need to provide a better explanation of what you're 
trying to accomplish. I can think of lots of ways to do useful things 
with the output of dir(), but have no idea which one(s) you need.


I wanted to loop through entries as an exercise.  Although this
is not really necessary with `indir` as you can ask directly
if something is in a directory.



Perl6 has all the cool tools,.

:-)

Thank you for all the help!

-T


Re: I need `dir` help

2018-05-10 Thread Brandon Allbery
I think you'll need to provide a better explanation of what you're trying
to accomplish. I can think of lots of ways to do useful things with the
output of dir(), but have no idea which one(s) you need.

On Thu, May 10, 2018 at 7:52 PM, ToddAndMargo  wrote:

> On 05/10/2018 04:49 PM, ToddAndMargo wrote:
>
>> On 05/10/2018 04:43 PM, Brandon Allbery wrote:
>>
>>> On Thu, May 10, 2018 at 7:34 PM, ToddAndMargo >> > wrote:
>>>
>>> https://docs.perl6.org/routine/dir >> e/dir>
>>>
>>> perl6 -e 'my $x=dir; say "$x";'
>>>
>>> Does indeed read the directory, but give me one YUGE string.
>>> I need each entry to have some kind of a separator.
>>>
>>>
>>> I'd say you did that to yourself, by wrapping it in quotes thereby
>>> forcing it to turn into a simple single string. $x itself is a Seq of
>>> IO::Path objects.
>>>
>>> It will be easier to track this if you capture into an array (@x instead
>>> of $x) and iterate over the contents. Or iterate directly:
>>>
>>> pyanfar Z$ 6 'for dir() -> $x { say "$x" }'
>>> debian-8.2.0-amd64-lxde-CD-1.iso
>>> lb.txt
>>> screenshotF-20161029T192446.png
>>> haskell-report-1.4.ps.gz
>>> hkcart.jpg
>>> (...)
>>>
>>> I'm quoting $x there for the same reason, to turn the IO::Path into a
>>> Str. Although arguably the correct way to do that is $x.Str instead of "$x".
>>>
>>
>> I get a bunch of quotes and .IO's
>>
>> :'(
>>
>>
>>
>> $ perl6 -e 'for dir() -> $x { say $x };'
>> "eraseme.pl6".IO
>> "crashme.pl6".IO
>> "DisableCaplock".IO
>> "OpenSmartSuite".IO
>>
>
>
> using "$x" removes the quotes and .IO, but I need to test each
> line without the quotes and .IO's
>
>
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>



-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: I need `dir` help

2018-05-10 Thread ToddAndMargo

On 05/10/2018 04:52 PM, Brandon Allbery wrote:
The last line of my message, quoted above, is there for a reason. An 
IO::Path is not a Str.


I understand now.  Thank you!


Re: I need `dir` help

2018-05-10 Thread ToddAndMargo

On 05/10/2018 04:52 PM, ToddAndMargo wrote:

On 05/10/2018 04:49 PM, ToddAndMargo wrote:

On 05/10/2018 04:43 PM, Brandon Allbery wrote:
On Thu, May 10, 2018 at 7:34 PM, ToddAndMargo > wrote:


    https://docs.perl6.org/routine/dir 



    perl6 -e 'my $x=dir; say "$x";'

    Does indeed read the directory, but give me one YUGE string.
    I need each entry to have some kind of a separator.


I'd say you did that to yourself, by wrapping it in quotes thereby 
forcing it to turn into a simple single string. $x itself is a Seq of 
IO::Path objects.


It will be easier to track this if you capture into an array (@x 
instead of $x) and iterate over the contents. Or iterate directly:


pyanfar Z$ 6 'for dir() -> $x { say "$x" }'
debian-8.2.0-amd64-lxde-CD-1.iso
lb.txt
screenshotF-20161029T192446.png
haskell-report-1.4.ps.gz
hkcart.jpg
(...)

I'm quoting $x there for the same reason, to turn the IO::Path into a 
Str. Although arguably the correct way to do that is $x.Str instead 
of "$x".


I get a bunch of quotes and .IO's

:'(



$ perl6 -e 'for dir() -> $x { say $x };'
"eraseme.pl6".IO
"crashme.pl6".IO
"DisableCaplock".IO
"OpenSmartSuite".IO



using "$x" removes the quotes and .IO, but I need to test each
line without the quotes and .IO's






This works:
$ perl6 -e 'for dir() -> $x { my $y="$x"; say $y };'
eraseme.pl6
crashme.pl6
DisableCaplock
...


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need `dir` help

2018-05-10 Thread Brandon Allbery
On Thu, May 10, 2018 at 7:49 PM, ToddAndMargo  wrote:

> On 05/10/2018 04:43 PM, Brandon Allbery wrote:
>
>> On Thu, May 10, 2018 at 7:34 PM, ToddAndMargo > > wrote:
>> It will be easier to track this if you capture into an array (@x instead
>> of $x) and iterate over the contents. Or iterate directly:
>>
>> pyanfar Z$ 6 'for dir() -> $x { say "$x" }'
>> debian-8.2.0-amd64-lxde-CD-1.iso
>> lb.txt
>> screenshotF-20161029T192446.png
>> haskell-report-1.4.ps.gz
>> hkcart.jpg
>> (...)
>>
>> I'm quoting $x there for the same reason, to turn the IO::Path into a
>> Str. Although arguably the correct way to do that is $x.Str instead of "$x".
>>
>
> I get a bunch of quotes and .IO's
>

The last line of my message, quoted above, is there for a reason. An
IO::Path is not a Str.

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: I need `dir` help

2018-05-10 Thread ToddAndMargo

On 05/10/2018 04:49 PM, ToddAndMargo wrote:

On 05/10/2018 04:43 PM, Brandon Allbery wrote:
On Thu, May 10, 2018 at 7:34 PM, ToddAndMargo > wrote:


    https://docs.perl6.org/routine/dir 



    perl6 -e 'my $x=dir; say "$x";'

    Does indeed read the directory, but give me one YUGE string.
    I need each entry to have some kind of a separator.


I'd say you did that to yourself, by wrapping it in quotes thereby 
forcing it to turn into a simple single string. $x itself is a Seq of 
IO::Path objects.


It will be easier to track this if you capture into an array (@x 
instead of $x) and iterate over the contents. Or iterate directly:


pyanfar Z$ 6 'for dir() -> $x { say "$x" }'
debian-8.2.0-amd64-lxde-CD-1.iso
lb.txt
screenshotF-20161029T192446.png
haskell-report-1.4.ps.gz
hkcart.jpg
(...)

I'm quoting $x there for the same reason, to turn the IO::Path into a 
Str. Although arguably the correct way to do that is $x.Str instead of 
"$x".


I get a bunch of quotes and .IO's

:'(



$ perl6 -e 'for dir() -> $x { say $x };'
"eraseme.pl6".IO
"crashme.pl6".IO
"DisableCaplock".IO
"OpenSmartSuite".IO



using "$x" removes the quotes and .IO, but I need to test each
line without the quotes and .IO's



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~


Re: I need `dir` help

2018-05-10 Thread ToddAndMargo

On 05/10/2018 04:43 PM, Brandon Allbery wrote:
On Thu, May 10, 2018 at 7:34 PM, ToddAndMargo > wrote:


https://docs.perl6.org/routine/dir 

perl6 -e 'my $x=dir; say "$x";'

Does indeed read the directory, but give me one YUGE string.
I need each entry to have some kind of a separator.


I'd say you did that to yourself, by wrapping it in quotes thereby 
forcing it to turn into a simple single string. $x itself is a Seq of 
IO::Path objects.


It will be easier to track this if you capture into an array (@x instead 
of $x) and iterate over the contents. Or iterate directly:


pyanfar Z$ 6 'for dir() -> $x { say "$x" }'
debian-8.2.0-amd64-lxde-CD-1.iso
lb.txt
screenshotF-20161029T192446.png
haskell-report-1.4.ps.gz
hkcart.jpg
(...)

I'm quoting $x there for the same reason, to turn the IO::Path into a 
Str. Although arguably the correct way to do that is $x.Str instead of "$x".


I get a bunch of quotes and .IO's

:'(



$ perl6 -e 'for dir() -> $x { say $x };'
"eraseme.pl6".IO
"crashme.pl6".IO
"DisableCaplock".IO
"OpenSmartSuite".IO


Re: I need `dir` help

2018-05-10 Thread Brandon Allbery
On Thu, May 10, 2018 at 7:34 PM, ToddAndMargo  wrote:

> https://docs.perl6.org/routine/dir
>
> perl6 -e 'my $x=dir; say "$x";'
>
> Does indeed read the directory, but give me one YUGE string.
> I need each entry to have some kind of a separator.
>

I'd say you did that to yourself, by wrapping it in quotes thereby forcing
it to turn into a simple single string. $x itself is a Seq of IO::Path
objects.

It will be easier to track this if you capture into an array (@x instead of
$x) and iterate over the contents. Or iterate directly:

pyanfar Z$ 6 'for dir() -> $x { say "$x" }'
debian-8.2.0-amd64-lxde-CD-1.iso
lb.txt
screenshotF-20161029T192446.png
haskell-report-1.4.ps.gz
hkcart.jpg
(...)

I'm quoting $x there for the same reason, to turn the IO::Path into a Str.
Although arguably the correct way to do that is $x.Str instead of "$x".

-- 
brandon s allbery kf8nh   sine nomine associates
allber...@gmail.com  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonadhttp://sinenomine.net


Re: I need `dir` help

2018-05-10 Thread jerry gay
i'm afraid you didn't read the docs very closely...

Returns the contents of a directory as a lazy list of IO::Path objects


stringifying an IO::Path object gives you a large string.

the examples in the docs take up more room than the description of the
routine. here's the first:

Examples:
> # To iterate over the contents of the current directory:
> for dir() -> $file {
> say $file;
> }


i suspect iterating over the contents of the object returned by the dir
routine, as documented in the link you provided, will produce the expected
results.

~particle

On Thu, May 10, 2018 at 4:34 PM, ToddAndMargo  wrote:

> Hi All,
>
> https://docs.perl6.org/routine/dir
>
> perl6 -e 'my $x=dir; say "$x";'
>
> Does indeed read the directory, but give me one YUGE string.
> I need each entry to have some kind of a separator.
>
>
> Many thanks,
> -T
>
>
> --
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~
>


I need `dir` help

2018-05-10 Thread ToddAndMargo

Hi All,

https://docs.perl6.org/routine/dir

perl6 -e 'my $x=dir; say "$x";'

Does indeed read the directory, but give me one YUGE string.
I need each entry to have some kind of a separator.


Many thanks,
-T


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~