Re: "index" source code?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 7:20 AM, Brad Gilbert wrote: The Rakudo Perl6 compilier is written in Perl6 (and a subset of Perl6 named NQP) The `index` subroutines are at https://github.com/rakudo/rakudo/blob/64c88f919841c58f5a6dffd3581770e06a8fd6a5/src/core/Cool.pm6#L276-L282 proto sub index($, $, $?, *%)

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 1:55 AM, David Warring wrote: Are all characters in the range 0-255, ie latin-1 characters? You could then try: my $str =  $buf.decode("latin-1"); There's one potential  issue if your data could contain DOS end of lines ("\r\n"), which will get translated to a single logical "\n" in

Re: binary test and position?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/2/19 9:29 PM, Brad Gilbert wrote: It is also weird that you are using CamelCase for variables, and a mixture of CamelCase and snake-case for the subroutine name. Hi Brad, An explanation. I do this for "maintainability". I have been able to "type" since high school typing class. Upper

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread David Warring
Are all characters in the range 0-255, ie latin-1 characters? You could then try: my $str = $buf.decode("latin-1"); There's one potential issue if your data could contain DOS end of lines ("\r\n"), which will get translated to a single logical "\n" in the decoded string. - David On Sun, Feb

Re: "index" source code?

2019-02-03 Thread Brad Gilbert
The Rakudo Perl6 compilier is written in Perl6 (and a subset of Perl6 named NQP) The `index` subroutines are at https://github.com/rakudo/rakudo/blob/64c88f919841c58f5a6dffd3581770e06a8fd6a5/src/core/Cool.pm6#L276-L282 proto sub index($, $, $?, *%) {*} multi sub index(Cool $s, Cool

decode options?

2019-02-03 Thread ToddAndMargo via perl6-users
Hi All, Uhhh, https://docs.perl6.org/routine/decode role Blob From Blob (Blob) method decode Defined as: multi method decode(Blob:D: Str:D $encoding = 'UTF-8' --> Str:D) Applies an encoding to turn the blob into a Str. my Blob $blob =

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread Darren Duncan
On 2019-02-02 7:22 PM, ToddAndMargo via perl6-users wrote: I need to read a file into a buffer (NO CONVERSIONS!) and then convert it to a string (again with no conversions). I think you're making an impossible request. If preserving exact bytes is important, then you want to keep your data

Re: Fastest way to convert from a Buf to a Str?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 5:26 PM, Darren Duncan wrote: On 2019-02-02 7:22 PM, ToddAndMargo via perl6-users wrote: I need to read a file into a buffer (NO CONVERSIONS!) and then convert it to a string (again with no conversions). I think you're making an impossible request. Don't forget that I think

Re: decode options?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 4:56 PM, ToddAndMargo via perl6-users wrote: Hi All, Uhhh,     https://docs.perl6.org/routine/decode    role Blob    From Blob    (Blob) method decode    Defined as:    multi method decode(Blob:D: Str:D $encoding = 'UTF-8' --> Str:D)    Applies an

"read" options?

2019-02-03 Thread ToddAndMargo via perl6-users
Hi All, https://docs.perl6.org/routine/read Where is the list of the options this thing will take, such as :ro and :bin? Many thanks, -T

Re: "read" options?

2019-02-03 Thread Norman Gaywood
On Mon, 4 Feb 2019 at 15:12, ToddAndMargo via perl6-users < perl6-users@perl.org> wrote: > https://docs.perl6.org/routine/read > > Where is the list of the options this thing will take, such > as :ro and :bin? > > Those are options for open() https://docs.perl6.org/routine/open -- Norman

Re: "read" options?

2019-02-03 Thread ToddAndMargo via perl6-users
On 2/3/19 8:46 PM, Norman Gaywood wrote: On Mon, 4 Feb 2019 at 15:12, ToddAndMargo via perl6-users mailto:perl6-users@perl.org>> wrote: https://docs.perl6.org/routine/read Where is the list of the options this thing will take, such as :ro and :bin? Those are options for open()

reassigning values to variables question

2019-02-03 Thread ToddAndMargo via perl6-users
Hi All, If I have a variable of type Buf which 1000 bytes in it and I find the five bytes I want, is it faster, slower, or no difference in speed to overwrite the same variable with the five bytes? Or is it faster to put the five bytes from the first variable into a second variable? Many