On 10/29/2017 11:18 PM, ToddAndMargo wrote:
Dear List,
I am trying to translate this P5 coder to P6.
I am looking at how to read a pipe into a line liner:
Follow up:
With the help of the guys on the chat line, here is
the keeper file I wrote myself:
-T
How to read a "pipe":
.lines gives you an array of lines, each with the trailing newline removed
All three of the follow output the data without the formatting:
$ ls *Test.pl6* | perl6 -e 'say "$*IN.lines;'
$ ls *Test.pl6* | perl6 -e 'my $x=lines(); say "$x";'
$ ls *Test.pl6* | perl6 -e 'my $x=get(); say "$x";'
CallFrameTest.pl6 CommandLineTest.pl6 CurlUtilsTest.pl6 FileTest.pl6
HashIndexTest.pl6 InlineTest.pl6 LogTest.pl6 LogTest.pl6.log
MonthTest.pl6 RunNoShellTest.pl6 ShArTest.pl6 SubTest.pl6 TermTest.pl6
Timo.Attachmnet.Test.pl6 X11Clipboard.Test.pl6 X11Test.pl6 Xlib.Test.pl6
"get" reads one line at a time into a string (the whole thing into
an array)
$ ls *Test.pl6* | perl6 -e 'say get(); say get(); say get();'
CallFrameTest.pl6
CommandLineTest.pl6
CurlUtilsTest.pl6
"slurp" is the only one that keeps the entire original bash command's
formatting into a string:
$ ls *Test.pl6* | perl6 -e 'my $x=slurp(); say "$x";'
$ ls *Test.pl6* | perl6 -e 'my @x=$*IN.lines; for @x { say $_ };'
CallFrameTest.pl6
CommandLineTest.pl6
...
X11Test.pl6
Xlib.Test.pl6
$ ls *Test.pl6* | perl6 -e 'my $x=$*IN.slurp; say "$x";'
CallFrameTest.pl6
CommandLineTest.pl6
...
X11Test.pl6
Xlib.Test.pl6