Re: Using raku/perl6 as unix "cat"....

2020-01-21 Thread Todd Chester via perl6-users
On 2020-01-21 11:08, William Michels via perl6-users wrote: Good answers, all. Thanks to everyone for contributing. For anyone who wants a golfed "cat" replacement, command line arguments can give you shorter code: Hi William, I don't know if I contributed anything at all, but you are most

Re: Using raku/perl6 as unix "cat"....

2020-01-21 Thread Andy Bach
($val = pop(@ary)); From: William Michels via perl6-users Sent: Tuesday, January 21, 2020 1:08 PM To: Trey Harris ; perl6-users Cc: Andrew Shitov ; Curt Tilmes ; Joseph Brenner ; ToddAndMargo ; yary ; Elizabeth Mattijsen ; ngayw...@une.edu.au Subject: Re: Using r

Re: Using raku/perl6 as unix "cat"....

2020-01-21 Thread William Michels via perl6-users
Good answers, all. Thanks to everyone for contributing. For anyone who wants a golfed "cat" replacement, command line arguments can give you shorter code: mydir$ perl6 -e '.say for lines' ab_cd.txt a b c d mydir$ perl6 -ne '.say' ab_cd.txt a b c d mydir$ # below two single quotes as empty ar

Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Elizabeth Mattijsen
> On 21 Jan 2020, at 01:01, Norman Gaywood wrote: > On Tue, 21 Jan 2020 at 03:12, Brad Gilbert wrote: > .say for lines > > Since .say calls gist(), would it be not be better/safer to call .put instead? > >.put for lines Since lines only produces Str objects, and both Str.Str and Str.g

Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Trey Harris
On Mon, Jan 20, 2020 at 19:03 Trey Harris wrote: > On Mon, Jan 20, 2020 at 02:59 William Michels via perl6-users < > perl6-users@perl.org> wrote: > >> Hi Yary (and Todd), >> >> Thank you both for your responses. Yary, the problem seems to be with >> "get". I can change 'while' to 'for' below, but

Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Trey Harris
On Mon, Jan 20, 2020 at 19:01 Norman Gaywood wrote: > > On Tue, 21 Jan 2020 at 03:12, Brad Gilbert wrote: > >> .say for lines >> > > Since .say calls gist(), would it be not be better/safer to call .put > instead? > >.put for lines > If being set directly from `lines`, I can’t see when

Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Trey Harris
On Mon, Jan 20, 2020 at 02:59 William Michels via perl6-users < perl6-users@perl.org> wrote: > Hi Yary (and Todd), > > Thank you both for your responses. Yary, the problem seems to be with > "get". I can change 'while' to 'for' below, but using 'get' raku/perl6 > actually returns fewer lines with

Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Norman Gaywood
On Tue, 21 Jan 2020 at 03:12, Brad Gilbert wrote: > .say for lines > Since .say calls gist(), would it be not be better/safer to call .put instead? .put for lines -- Norman Gaywood, Computer Systems Officer School of Science and Technology University of New England Armidale NSW 2351, A

Re: Using raku/perl6 as unix "cat"....

2020-01-20 Thread Brad Gilbert
.say for lines On Mon, Jan 20, 2020 at 1:59 AM William Michels via perl6-users < perl6-users@perl.org> wrote: > Hi Yary (and Todd), > > Thank you both for your responses. Yary, the problem seems to be with > "get". I can change 'while' to 'for' below, but using 'get' raku/perl6 > actually ret

Re: Using raku/perl6 as unix "cat"....

2020-01-19 Thread William Michels via perl6-users
Hi Yary (and Todd), Thank you both for your responses. Yary, the problem seems to be with "get". I can change 'while' to 'for' below, but using 'get' raku/perl6 actually returns fewer lines with "for" than it did with "while": [1]mydir$ cat testthis_abc_def.txt a b c d e f [2]mydir$ perl6 -e '.s

Re: Using raku/perl6 as unix "cat"....

2020-01-18 Thread ToddAndMargo via perl6-users
On 2020-01-18 17:54, yary wrote: "while" is the wrong looping construct for going over file lines, and that's across a great many computer languages. It will stop when it encounters a false line- typically an empty line or '0' Try "for" -y Hi William, I don't know if this will help you, b

Re: Using raku/perl6 as unix "cat"....

2020-01-18 Thread yary
"while" is the wrong looping construct for going over file lines, and that's across a great many computer languages. It will stop when it encounters a false line- typically an empty line or '0' Try "for" -y On Sat, Jan 18, 2020 at 4:45 PM William Michels wrote: > Hello All, > > I've been revi

Using raku/perl6 as unix "cat"....

2020-01-18 Thread William Michels via perl6-users
Hello All, I've been reviewing literature that discusses using raku/perl6 as a replacement for common unix utilities. One important unix utility is "cat". I looked at docs/blogs and found a recommendation to use "$*IN" along with "slurp" (references at bottom). Using a seven-line test file "testth