Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 5:42 AM, Fernando Santagata wrote: The answer Laurent Roseenfeld gave you works for read and readchars as well. Save the following lines in a file and run it (try and change .read into .readchars too); it will output a series of 10-byte long Buf[uint8]s, until it reaches the end of

Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
Le mar. 9 oct. 2018 à 14:49, ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> a écrit : On 10/9/18 5:42 AM, Fernando Santagata wrote: > The answer Laurent Roseenfeld gave you works for read and readchars as well. > Save the following lines in a file and run it (try

Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 6:22 AM, Curt Tilmes wrote: On Tue, Oct 9, 2018 at 8:49 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: I am not getting anywhere with `.lines`.  Read the whole thing in the first line. $ p6 'my $fh=open "/home/linuxutil/WhoIsMySub.pl6", :r; 

Re: How do I Stringy a Buf?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 4:36 PM, ToddAndMargo via perl6-users wrote: $ p6 'my $fh=open "/home/linuxutil/WhoIsMySub.pl6", :r;  my Buf $f = $fh.read(100); $fh.close; say "<" ~ $f.decode("utf-8") ~ ">";' I changed `$f.decode("utf-8")` to `$f.decode("utf8-c8")` as you never know what a web page will have on

Re: How do I Stringy a Buf?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 6:26 AM, Curt Tilmes wrote: On Tue, Oct 9, 2018 at 9:21 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: Yes, I know there are other ways to read a file.  I have a specific reason for using `read`. How do I properly turn a Buf into a Str (all the

Re: Use of the --output flag

2018-10-09 Thread Simon Proctor
100% thanks a lot. :) On Tue, 9 Oct 2018 at 16:31, Timo Paulssen wrote: > --output is for the compiler's compilation stages > > for example: > > timo@schmand ~> perl6 --output=/tmp/outputtest --target=mbc -e 'say "hi"' > timo@schmand ~> moar --dump /tmp/outputtest | head > > MoarVM dump of

Re: Use of the --output flag

2018-10-09 Thread Timo Paulssen
--output is for the compiler's compilation stages for example: > timo@schmand ~> perl6 --output=/tmp/outputtest --target=mbc -e 'say "hi"' > timo@schmand ~> moar --dump /tmp/outputtest | head > > MoarVM dump of binary compilation unit: > >   SC_0 : B1DFAD9164F11E967B354508CC458ABAB8DEDC27 >  

Re: eof ?

2018-10-09 Thread Brad Gilbert
That isn't the syntax for a loop local variable in Perl 6. You are trying to use the Perl 5 syntax, which is not going to work in Perl 6 This is the Perl 5 code you are trying to write while( my $f = readline $fh ){ say "$f\n"} Which actually would turn into the following by Perl 5

Re: Use of the --output flag

2018-10-09 Thread Simon Proctor
It feels like a bug. I more wanted to know if anyone knew anything about it for the talk. Thanks On Tue, 9 Oct 2018, 14:49 Brad Gilbert, wrote: > My guess is that this is a bug. > > You can work around it by adding > > my $*OUT = q[test].IO.open(:w); > > in front of the code. > On Tue, Oct

Re: Use of the --output flag

2018-10-09 Thread Brad Gilbert
My guess is that this is a bug. You can work around it by adding my $*OUT = q[test].IO.open(:w); in front of the code. On Tue, Oct 9, 2018 at 8:18 AM Simon Proctor wrote: > > So... I'm working through some notes for a talk on Thursday and I am trying > to work out how the --output flag is

Re: eof ?

2018-10-09 Thread Brad Gilbert
On Tue, Oct 9, 2018 at 8:31 AM Curt Tilmes wrote: > > On Tue, Oct 9, 2018 at 9:27 AM Laurent Rosenfeld via perl6-users > wrote: >> >> This: >> my $f = $fh.lines; >> will slurp all the lines into $f (but you can still access the individual >> items with something like $f[4]). > > > Is that

Re: eof ?

2018-10-09 Thread Laurent Rosenfeld via perl6-users
Yes, you're right, it is a Seq. I was trying to be pedagogical, but probably wasn't very accurate. It is a Seq, and the "slurping" will be lazy. Le mar. 9 oct. 2018 à 15:30, Curt Tilmes a écrit : > On Tue, Oct 9, 2018 at 9:27 AM Laurent Rosenfeld via perl6-users < > perl6-users@perl.org>

Re: eof ?

2018-10-09 Thread Curt Tilmes
On Tue, Oct 9, 2018 at 9:27 AM Laurent Rosenfeld via perl6-users < perl6-users@perl.org> wrote: > This: > my $f = $fh.lines; > will slurp all the lines into $f (but you can still access the individual > items with something like $f[4]). > Is that true? I supposed that it would hold the Seq as a

Re: eof ?

2018-10-09 Thread Laurent Rosenfeld via perl6-users
This: my $f = $fh.lines; will slurp all the lines into $f (but you can still access the individual items with something like $f[4]). So you don't want to use this in a while loop, since everything will be consumed during the first loop iteration. Either use a for loop to process the lines one by

Re: How do I Stringy a Buf?

2018-10-09 Thread Curt Tilmes
On Tue, Oct 9, 2018 at 9:21 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > > Yes, I know there are other ways to read a file. I > have a specific reason for using `read`. > > How do I properly turn a Buf into a Str (all the bytes will > have been tested to make sure they are

Re: eof ?

2018-10-09 Thread Curt Tilmes
On Tue, Oct 9, 2018 at 8:49 AM ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > > I am not getting anywhere with `.lines`. Read the whole thing in the > first line. > > $ p6 'my $fh=open "/home/linuxutil/WhoIsMySub.pl6", :r; while my $f = > $fh.lines { say "$f\n"}; $fh.close;' >

How do I Stringy a Buf?

2018-10-09 Thread ToddAndMargo via perl6-users
Hi All, Yes, I know there are other ways to read a file. I have a specific reason for using `read`. How do I properly turn a Buf into a Str (all the bytes will have been tested to make sure they are printable first)? $ p6 'my $fh=open "/home/linuxutil/WhoIsMySub.pl6", :r; my Buf $f =

Use of the --output flag

2018-10-09 Thread Simon Proctor
So... I'm working through some notes for a talk on Thursday and I am trying to work out how the --output flag is supposed to work. I would expect this to create a file called test and print "Hi\n" in it : perl6 --output=test -e 'say "Hi"' But instead I got Hi printed to the command line and an

Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 5:42 AM, Fernando Santagata wrote: The answer Laurent Roseenfeld gave you works for read and readchars as well. Save the following lines in a file and run it (try and change .read into .readchars too); it will output a series of 10-byte long Buf[uint8]s, until it reaches the end of

Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 5:03 AM, ToddAndMargo via perl6-users wrote: Le mar. 9 oct. 2018 à 10:03, ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> a écrit :     Hi All,     When reading a text file     https://docs.perl6.org/routine/lines     seems pretty straight forward.     Question:  How do

Re: eof ?

2018-10-09 Thread Fernando Santagata
The answer Laurent Roseenfeld gave you works for read and readchars as well. Save the following lines in a file and run it (try and change .read into .readchars too); it will output a series of 10-byte long Buf[uint8]s, until it reaches the end of file. #!/usr/bin/env perl6 given

Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
Le mar. 9 oct. 2018 à 10:03, ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> a écrit : Hi All, When reading a text file https://docs.perl6.org/routine/lines seems pretty straight forward. Question: How do I tell when I when I have reached the EOF (End Of

Re: j ?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/7/18 1:25 AM, ToddAndMargo via perl6-users wrote: Hi All, I am going to possibly be writing binary code to my terminal. This can really screw up your terminal.  THe solution is to enter sane^j on your keyboard.  The ^ above is holding down your key. I would like to be able to

Re: eof ?

2018-10-09 Thread Laurent Rosenfeld via perl6-users
The eof method of the IO::Handle class returns True if you exhausted the contents of the handle, but you generally don't need to use that, since something like: for 'input.txt'.IO.lines -> $line { # Do something with $line } will gracefully handle ends of files for you without you having to

Re: loop on a Buf/binary

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/8/18 5:33 AM, Curt Tilmes wrote: On Mon, Oct 8, 2018 at 7:53 AM ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: I take it that `Buf` is a special type of array that the normal rules do not apply to. I would say rather than each of them (Buf and Array) are

Re: eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
On 10/9/18 1:02 AM, ToddAndMargo via perl6-users wrote: Hi All, When reading a text file     https://docs.perl6.org/routine/lines seems pretty straight forward. Question:  How do I tell when I when I have reached the EOF (End Of File)? Many thanks, -T Please expand the question to include

eof ?

2018-10-09 Thread ToddAndMargo via perl6-users
Hi All, When reading a text file https://docs.perl6.org/routine/lines seems pretty straight forward. Question: How do I tell when I when I have reached the EOF (End Of File)? Many thanks, -T