Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
On Thu, Dec 20, 2018 at 5:17 PM ToddAndMargo via perl6-users wrote: El jue., 20 dic. 2018 21:43, ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> escribió: Hi All, Exactly what is type "Match"? Here I want $D0..$D3 to only be strings. And it thro

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
On 12/20/18 2:59 PM, Laurent Rosenfeld via perl6-users wrote: $0 /does /work with "perl6 -e" if you use correctly the tilde ~ operator. For example: $ perl6 -e ' "abc" ~~ /.(\w)./; say ~$0;' b This is because "say" is also a converter. My issue is when assigning to another variable that has

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
On 12/20/18 2:49 PM, Laurent Rosenfeld via perl6-users wrote: $D0 = ~$0; $D1 = ~$1; # ... Hi Laurent, Except that it crashed in "perl6 -e", which is where I do all my syntax testing. Is okay, Perl was 101 ways of doing everything, so I can still "get 'er done". I also instantly recognize .St

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
On 12/20/18 2:49 PM, Laurent Rosenfeld via perl6-users wrote: JJ Merelo accurately responded Absolutely. He just did not answer the question I asked. JJ make a mistake? The earth would wobble on its access!!

Re: Exactly what is type match?

2018-12-20 Thread ToddAndMargo via perl6-users
On 12/20/18 3:51 PM, ToddAndMargo via perl6-users wrote: On 12/20/18 2:49 PM, Laurent Rosenfeld via perl6-users wrote: JJ Merelo accurately responded Absolutely.  He just did not answer the question I asked. JJ make a mistake?  The earth would wobble on its access!! chuckle: Axis

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
On 12/21/18 12:58 AM, Laurent Rosenfeld via perl6-users wrote: You're free to use a Str method call if you prefer, but using the ~ to stringify $0 and the like works perfectly for me in perl -e ... context. $ perl6 -e' "abc" ~~ /.(\w)./; put $0.perl; my $c = ~$0; put $c;' Match.new(list => (),

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
On 12/20/18 10:32 PM, JJ Merelo wrote: I didn't think I needed to answer a question that can be so easily obtained from the documentation: https://docs.perl6.org/type/Match, which, unsurprisingly, says: "|Match| objects are the result of a successful regex match" That I knew. I was looking

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
On 12/21/18 11:46 AM, Timo Paulssen wrote: On 21/12/2018 20:38, ToddAndMargo via perl6-users wrote: $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+) [.] (\d+) }; $D0 ~$0; $D1 ~ $1;  print "$D0 $D1\n";' WARNINGS for -e: Useless use of "~&

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
On 12/21/18 12:13 PM, Timo Paulssen wrote: Like this? > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+) [.] > (\d+)}; $D0 ~= $0; $D1 ~= $1; print "$D0 $D1\n";' > > 11 2 > There's an important difference between "$D1 ~= $0" and "$D1 = ~$0". They only do the same thing if $D0 (a

Re: Exactly what is type match?

2018-12-21 Thread ToddAndMargo via perl6-users
On 12/21/18 12:28 PM, ToddAndMargo via perl6-users wrote: On 12/21/18 12:13 PM, Timo Paulssen wrote: Like this?  > > $ p6 'my $x="11.2."; my Str $D0; my Str $D1; $x~~m{ (<:N>+) [.] > (\d+)}; $D0 ~= $0; $D1 ~= $1; print "$D0 $D1\n";' > > 1

Bad syntax check

2019-01-02 Thread ToddAndMargo via perl6-users
Dear Perl 6 Developers, Fedora 29, x64 Xfce 4.13 $ perl6 -v This is Rakudo version 2018.11 built on MoarVM version 2018.11 implementing Perl 6.d. I am constantly improving (changing things) in my subs, etc.. As such, the things I return often change. Because of this, I have a found so

Re: Bad syntax check

2019-01-02 Thread ToddAndMargo via perl6-users
On 1/2/19 2:11 PM, Simon Proctor wrote: Have you tried defining your return values in the signature? sub AddThree( Int $a, Int $b, Int $c --> Int) {...} With this the compiler knows what your function is supposed to return and can earn you in advance. I did and it blew up in my face so I sto

Re: Bad syntax check

2019-01-02 Thread ToddAndMargo via perl6-users
On 1/2/19 2:27 PM, ToddAndMargo via perl6-users wrote: On 1/2/19 2:11 PM, Simon Proctor wrote: Have you tried defining your return values in the signature? sub AddThree( Int $a, Int $b, Int $c --> Int) {...} With this the compiler knows what your function is supposed to return and can e

Re: Bad syntax check

2019-01-02 Thread ToddAndMargo via perl6-users
On 1/2/19 4:00 PM, Brad Gilbert wrote: You can only list one type as a return type. If there were a hypothetical Tuple type:     sub AddThree( Int $a, Int $b, Int $c --> Tuple[Str, Int] {         my Int $d = $a + $b + $c;         return Tuple[Str,Int].new( "a+b+c=", $d );     } I drew the

**@args question

2019-01-02 Thread ToddAndMargo via perl6-users
Hi All, Looking at https://docs.perl6.org/routine/print I see multi sub print(**@args --> True) Question. If I wanted to create my own print routine using **@args, how would I declare it? sub printx( **@args data ) {...} Many thanks, -T -- ~~

Re: **@args question

2019-01-02 Thread ToddAndMargo via perl6-users
> On Wed, Jan 2, 2019 at 8:41 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> Looking at >> >> https://docs.perl6.org/routine/print >> >> I see >> >> multi sub print(**@args --> True) >> >> Qu

Re: **@args question

2019-01-02 Thread ToddAndMargo via perl6-users
On 1/2/19 10:17 PM, ToddAndMargo via perl6-users wrote: > On Wed, Jan 2, 2019 at 8:41 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> Looking at >> >>  https://docs.perl6.org/routine/print >> >> I see >>

Re: **@args question

2019-01-04 Thread ToddAndMargo via perl6-users
On 1/3/19 2:58 AM, Brad Gilbert wrote: On Thu, Jan 3, 2019 at 12:43 AM ToddAndMargo via perl6-users wrote: On 1/2/19 10:17 PM, ToddAndMargo via perl6-users wrote: > On Wed, Jan 2, 2019 at 8:41 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All,

Re: **@args question

2019-01-04 Thread ToddAndMargo via perl6-users
On 1/4/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/3/19 2:58 AM, Brad Gilbert wrote: On Thu, Jan 3, 2019 at 12:43 AM ToddAndMargo via perl6-users wrote: On 1/2/19 10:17 PM, ToddAndMargo via perl6-users wrote:   > On Wed, Jan 2, 2019 at 8:41 PM ToddAndMargo via perl6-us

Re: **@args question

2019-01-04 Thread ToddAndMargo via perl6-users
On 1/3/19 12:43 AM, Richard Hainsworth wrote: The term "slurpy" did help a lot. :-) I am writing your explanation down for my records. Well Golly! $ p6 'sub printx(**@args){print(@args)}; printx("abc",1,"def\n");' abc 1 def $ p6 'sub printx(**@args){print @args, "\n"}; printx("abc",1,"d

Re: Bad syntax check

2019-01-04 Thread ToddAndMargo via perl6-users
On 1/3/19 1:52 AM, JJ Merelo wrote: El mié., 2 ene. 2019 a las 21:04, ToddAndMargo via perl6-users (mailto:perl6-us...@perl.org>>) escribió: Dear Perl 6 Developers, Fedora 29, x64 Xfce 4.13 $ perl6 -v      This is Rakudo version 2018.11 built on MoarVM v

How do I trap a crash?

2019-01-11 Thread ToddAndMargo via perl6-users
Hi All, I would like to do a Send Notify when a program of mine crashes. How do I trap a crash? Is there a way to see some of the local variables in the sub that crashes with the trap? Many thanks, -T -- ~~ Computers are like air conditioners. They malfun

I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1234 ) ); say %Vendors;' ===SORRY!=== Error while compiling -e I want to be able to have both a Contact Name and and AccountNo associated with each key in %Vendors

Re: How do I trap a crash?

2019-01-11 Thread ToddAndMargo via perl6-users
thanks, >> -T On 1/11/19 10:56 AM, Elizabeth Mattijsen wrote: Perhaps https://docs.perl6.org/language/exceptions#Catching_exceptions could be enlightening? On 11 Jan 2019, at 18:54, ToddAndMargo via perl6-users wrote: Yes. Thank you! CATCH { default { $*ERR.say: .pay

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
n front of the () The working code looks like this: perl6 -e 'my %Vendors=("acme" => %( "ContactName" => "Larry", "AccountNo" => 1234 ) ); say %Vendors;' {acme => {AccountNo => 1234, ContactName => Larry}} Hope that helps!   - T

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:07 AM, JJ Merelo wrote: What would you say is the error, according to where the arrow points to? Maybe some unclosed double quotes? El vie., 11 ene. 2019 a las 19:57, ToddAndMargo via perl6-users (mailto:perl6-us...@perl.org>>) escribió: Hi All, How do I do

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:12 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:09 AM, Timo Paulssen wrote: Hi Todd, the error you're getting comes from a closing quotation mark missing after "Larry You will also need to give perl6 some hint that you want the list of pairs to actually bec

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:16 AM, Bruce Gray wrote: On Jan 11, 2019, at 12:41 PM, ToddAndMargo via perl6-users wrote: Hi All, How do I do a hash inside a hash? So far I have: $ p6 'my %Vendors=("acme" => ( "ContactName" => "Larry, "AccountNo" => 1

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup. I am on fire today! :'( Still can't get it figured out. :'( :'( $ p6 'my $x="Ace"; my %Vendors=("acme" => { "ContactName" => "Larry", "AccountNo" => 1234 }, "Ace" => { "ContactName" => "Mo", "AccountNo" =>

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup.  I am on fire today!  :'( Still can't get it figured out.  :'(  :'( $ p6 'my $x="Ace"; my %Vendors=("acme&quo

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:43 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup.  I am on fire today!  :'( Still can't get it figured out.  :'(  :'( $

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:50 AM, Bruce Gray wrote: 'my $x = "Ace"; my %Vendors = ( acme => { ContactName => "Larry", AccountNo => 1234 }, Ace => { ContactName => "Mo", AccountNo => "A102" } ); say %Vendors{$x} ~ "\t" ~ %Vendors{$x};’ Hi Bruce, Sweet! Thank you! $ p6 'my $x = "Ace"; my %Vendors = ( acme

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:45 AM, Bruce Gray wrote: Short answer: use `%hash{$var}`, not `%hash<$var>`. When they are not in position to be less-than and greater-than comparison operators, the pair of left and right angle brackets are a circumfix operator that work like Perl 5’s “quote word” op: `qw()`. I

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:50 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:43 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:39 AM, ToddAndMargo via perl6-users wrote: On 1/11/19 11:33 AM, JJ Merelo wrote: I think you want $x, not $Ace. Cheers Yup.  I am on fire today!  :'( Still

Re: I need hash inside a hash help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 11:59 AM, Bruce Gray wrote: That may work, but is bad practice. no fooling! look like hell too

subnet calculator

2019-01-11 Thread ToddAndMargo via perl6-users
Hi All, Anyone know if someone has written a program like this in Perl that will run locally and not require the Internet? http://www.subnet-calculator.com/ Many thanks, -T

Re: subnet calculator

2019-01-11 Thread ToddAndMargo via perl6-users
On Fri, Jan 11, 2019 at 3:08 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Hi All, Anyone know if someone has written a program like this in Perl that will run locally and not require the Internet? http://www.subnet-calculator.com/ Many

Re: subnet calculator

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 1:56 PM, Bruce Gray wrote: On Jan 11, 2019, at 2:07 PM, ToddAndMargo via perl6-users wrote: Hi All, Anyone know if someone has written a program like this in Perl that will run locally and not require the Internet? http://www.subnet-calculator.com/ Many thanks, -T I have

I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' Type check failed in assignment to $y; expected Str but got Any (Any) in block at -e line 1 $ p6

Re: I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doing wrong?  I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => "Larry" ); $y= %Vendors; say $y;' T

Re: I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 5:59 PM, Tom Browder wrote: On Fri, Jan 11, 2019 at 19:09 ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: Now what am I doing wrong?  I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y;

Re: I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 6:23 PM, Tom Browder wrote: On Fri, Jan 11, 2019 at 20:15 ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: ... > $p6 'my $x = "acme"; my %Vendors = ( acme => { ContactName => "Larry", > AccountNo => 1234 } ); m

Re: I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 6:35 PM, Bruce Gray wrote: On Jan 11, 2019, at 7:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doing wrong? I need to convert the value in a hash to a string: $ p6 'my $x = "acme"; my Str $y; my %Vendors = ( acme => ContactName => &qu

Re: I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
say $a before $b; # True There are useful methods on Versions my $a = v12.3.4.1; say $a.parts.perl; # (12, 3, 4, 1) On Fri, Jan 11, 2019 at 8:12 PM ToddAndMargo via perl6-users wrote: On 1/11/19 5:08 PM, ToddAndMargo via perl6-users wrote: Hi All, Now what am I doi

Re: I need hash string help

2019-01-11 Thread ToddAndMargo via perl6-users
On 1/11/19 6:51 PM, ToddAndMargo via perl6-users wrote: On 1/11/19 6:49 PM, Brad Gilbert wrote: $a is short for $a{'a','b'} This also happens in string literals my $a = { a => 1, b => 2 }; say "$a"; # 1 2 say "$a{'a','b&#x

I need m/ help

2019-01-12 Thread ToddAndMargo via perl6-users
Hi All, This works: $ p6 'my $x="2018-09-15"; $x~~s/ (<:N>+) "-" (<:N>+) "-" (<:N>+) /$0.$1.$2/; say $x;' 2018.09.15 And this does too: $ perl6 -e 'my Str $Date=DateTime.now.Str; $Date~~m/ (<:N>+) "-" (<:N>+) "-" (<:N>+) "T" .* /; print "$Date\n\t$0 $1 $2\n"' 2019-01-12T14:35:23.242587-

Re: I need m/ help

2019-01-13 Thread ToddAndMargo via perl6-users
On 1/12/19 3:04 PM, Timo Paulssen wrote: On 12/01/2019 23:40, ToddAndMargo via perl6-users wrote: But this does not.  What is wrong with (<:N>**2)  ? $ perl6 -e 'my Str $Date=DateTime.now.Str; $Date~~m/ (<:N>**4) "-" (<:N>**2) "-" (<:Nl>**2) &q

Re: I need m/ help

2019-01-13 Thread ToddAndMargo via perl6-users
On 1/12/19 3:04 PM, Timo Paulssen wrote: On 12/01/2019 23:40, ToddAndMargo via perl6-users wrote: But this does not.  What is wrong with (<:N>**2)  ? $ perl6 -e 'my Str $Date=DateTime.now.Str; $Date~~m/ (<:N>**4) "-" (<:N>**2) "-" (<:Nl>**2) &q

Re: I need m/ help

2019-01-13 Thread ToddAndMargo via perl6-users
On 1/13/19 2:04 PM, Brad Gilbert wrote: <:Nl> matches a Number that is letter-like Hi Brad and Timo, Now I understand. It is for non-Arabic numbers such as Roman numerals. Thank you! -T

filever.exe sub?

2019-01-29 Thread ToddAndMargo via perl6-users
Hi All, Windows provides a utility called filever.exe which will tell you the revision of and exe file. (You can also see this through the gui with properties). Currently I run filever.exe through Wine. It is cumbersome, especially since Wine floods STDERR. I work around it. Do we have a mod

Re: filever.exe sub?

2019-01-29 Thread ToddAndMargo via perl6-users
On 1/29/19 9:53 PM, ToddAndMargo via perl6-users wrote: Hi All, Windows provides a utility called filever.exe which will tell you the revision of and exe file.  (You can also see this through the gui with properties). Currently I run filever.exe through Wine.  It is cumbersome, especially

Re: filever.exe sub?

2019-01-31 Thread ToddAndMargo via perl6-users
On 1/29/19 9:53 PM, ToddAndMargo via perl6-users wrote: Hi All, Windows provides a utility called filever.exe which will tell you the revision of and exe file.  (You can also see this through the gui with properties). Currently I run filever.exe through Wine.  It is cumbersome, especially

Re: filever.exe sub?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 10:02 AM, Timo Paulssen wrote: On 01/02/2019 01:33, Bruce Gray wrote: To call those Windows APIs in Perl 6, you would use NativeCall. Don't forget that Todd wanted to use this on non-windows with not-wine. NativeCall on linux won't run windows code all by itself. That said, wine is

Re: filever.exe sub?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 4:26 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 10:02 AM, Timo Paulssen wrote: On 01/02/2019 01:33, Bruce Gray wrote: To call those Windows APIs in Perl 6, you would use NativeCall. Don't forget that Todd wanted to use this on non-windows with not-wine. NativeCall on

Re: filever.exe sub?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 6:24 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 4:26 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 10:02 AM, Timo Paulssen wrote: On 01/02/2019 01:33, Bruce Gray wrote: To call those Windows APIs in Perl 6, you would use NativeCall. Don't forget that Todd wanted t

binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
Hi All, On a type Buf, what do I use to check for the position of a byte pattern? Many thanks, -T

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 7:22 PM, ToddAndMargo via perl6-users wrote: Hi All, On a type Buf, what do I use to check for the position of a byte pattern? Many thanks, -T Basically, what am I doing wrong here? $ p6 'my $handle=open("filever.exe", :bin, :ro); my Buf $b; $b= $handle.read(5);

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
> > On Fri, Feb 1, 2019 at 9:22 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> On a type Buf, what do I use to check for the >> position of a byte pattern? >> >> >> Many thanks, >> -T On 2/1/19 7:35 PM, Brad Gilbert

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 7:37 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 7:22 PM, ToddAndMargo via perl6-users wrote: Hi All, On a type Buf, what do I use to check for the position of a byte pattern? Many thanks, -T Basically, what am I doing wrong here? $ p6 'my $handle=open("filever.

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
> On Fri, Feb 1, 2019 at 9:37 PM ToddAndMargo via perl6-users > wrote: >> >> On 2/1/19 7:22 PM, ToddAndMargo via perl6-users wrote: >>> Hi All, >>> >>> On a type Buf, what do I use to check for the >>> position of a byte pattern? >>

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 8:03 PM, ToddAndMargo via perl6-users wrote: > On Fri, Feb 1, 2019 at 9:37 PM ToddAndMargo via perl6-users > wrote: >> >> On 2/1/19 7:22 PM, ToddAndMargo via perl6-users wrote: >>> Hi All, >>> >>> On a type Buf, what do I use to

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 8:07 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 8:03 PM, ToddAndMargo via perl6-users wrote:  > On Fri, Feb 1, 2019 at 9:37 PM ToddAndMargo via perl6-users  > wrote:  >>  >> On 2/1/19 7:22 PM, ToddAndMargo via perl6-users wrote:  >>> Hi All,  >&g

Re: binary test and position?

2019-02-01 Thread ToddAndMargo via perl6-users
On 2/1/19 8:26 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 8:07 PM, ToddAndMargo via perl6-users wrote: On 2/1/19 8:03 PM, ToddAndMargo via perl6-users wrote:  > On Fri, Feb 1, 2019 at 9:37 PM ToddAndMargo via perl6-users  > wrote:  >>  >> On 2/1/19 7:22 PM, ToddAndMar

How do I use chr inside a regex?

2019-02-01 Thread ToddAndMargo via perl6-users
Hi All, How do I use chr inside a regex. In the below, how do I get rid of $y? $ p6 'my Str $x=chr(0x66)~chr(0x77); my Str $y=chr(0x66)~chr(0x77); $x~~s/ $y /xy/; say $x;' xy Many thanks, -T

Re: How do I use chr inside a regex?

2019-02-02 Thread ToddAndMargo via perl6-users
On 2/1/19 11:32 PM, JJ Merelo wrote: Hi, El sáb., 2 feb. 2019 a las 7:48, ToddAndMargo via perl6-users (mailto:perl6-us...@perl.org>>) escribió: Hi All, How do I use chr inside a regex.  In the below, how do I get rid of $y? $ p6 'my Str $x=chr(0x66)~chr(0x77)

Start reading at a specific index?

2019-02-02 Thread ToddAndMargo via perl6-users
Hi All, Is there a way to modify this to start reading at a specific index? And include how many bytes (300) to read as well? my $FileHandle = open( $FileName, :bin, :ro ); my Buf $BinaryFile = $FileHandle.read( 300 ); Many thanks, -T

faster than index?

2019-02-02 Thread ToddAndMargo via perl6-users
Hi All, What is the fastest way to find the index of a sub string in a string? -T

Re: faster than index?

2019-02-02 Thread ToddAndMargo via perl6-users
: https://github.com/rakudo/rakudo/blob/master/src/core/Str.pm6#L255-L284 - .indices: https://github.com/rakudo/rakudo/blob/master/src/core/Str.pm6#L206-L252 - .contains: https://github.com/rakudo/rakudo/blob/master/src/core/Str.pm6#L183-L203 - .rindex: https://github.com/rakudo/rakudo/blob/master/sr

Re: Start reading at a specific index?

2019-02-02 Thread ToddAndMargo via perl6-users
On 2/2/19 3:16 AM, Shlomi Fish wrote: On Sat, 2 Feb 2019 01:08:39 -0800 ToddAndMargo via perl6-users wrote: Hi All, Is there a way to modify this to start reading at a specific index? And include how many bytes (300) to read as well? my $FileHandle = open( $FileName, :bin

Re: binary test and position?

2019-02-02 Thread ToddAndMargo via perl6-users
> On Fri, Feb 1, 2019 at 11:02 PM ToddAndMargo via perl6-users> wrote: >> >> On 2/1/19 8:26 PM, ToddAndMargo via perl6-users wrote: >>> On 2/1/19 8:07 PM, ToddAndMargo via perl6-users wrote: >>>> On 2/1/19 8:03 PM, ToddAndMargo via perl6-users wrote: &

Fastest way to convert from a Buf to a Str?

2019-02-02 Thread ToddAndMargo via perl6-users
Hi All, I need to read a file into a buffer (NO CONVERSIONS!) and then convert it to a string (again with no conversions). I have been doing this: for ( @$BinaryFile ) -> $Char { $StrFile ~= chr($Char); } But it takes a bit of time. What is the fastest way to do this? I guess there is not

Fastest way to convert from a Buf to a Str?

2019-02-02 Thread ToddAndMargo via perl6-users
Hi All, I need to read a file into a buffer (NO CONVERSIONS!) and then convert it to a string (again with no conversions). I have been doing this: for ( @$BinaryFile ) -> $Char { $StrFile ~= chr($Char); } But it takes a bit of time. What is the fastest way to do this? I guess there is not

Re: binary test and position?

2019-02-02 Thread ToddAndMargo via perl6-users
On 2/2/19 6:09 AM, Brad Gilbert wrote: sub buf-index ( Buf $buf, +@match ) { my $elems = @match.elems; $buf.rotor( $elems => 1 - $elems ).first(* eqv @match.List, :k) } my $buf = Buf[uint8].new(0x4D, 0x5A, 0x90, 0x00, 0x03); say buf-index( $buf, (0x90, 0x00

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

2019-02-02 Thread ToddAndMargo via perl6-users
> > On Sat, Feb 2, 2019 at 9:23 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> I need to read a file into a buffer (NO CONVERSIONS!) >> and then convert it to a string (again with no >> conversions). >> >> I have been doing

Re: binary test and position?

2019-02-02 Thread ToddAndMargo via perl6-users
> On Sat, Feb 2, 2019 at 10:05 PM ToddAndMargo via perl6-users > wrote: >> >> On 2/2/19 6:09 AM, Brad Gilbert wrote: >>> sub buf-index ( Buf $buf, +@match ) { >>> my $elems = @match.elems; >>> $buf.rotor( $elems

"index" source code?

2019-02-02 Thread ToddAndMargo via perl6-users
Hi All, Was the subroutine "index" written Perl6? If so, where can I view the source code? Many thanks, -T

Re: Start reading at a specific index?

2019-02-02 Thread ToddAndMargo via perl6-users
> On Sat, Feb 2, 2019 at 9:02 PM ToddAndMargo via perl6-users > wrote: >> >> On 2/2/19 3:16 AM, Shlomi Fish wrote: >>> On Sat, 2 Feb 2019 01:08:39 -0800 >>> ToddAndMargo via perl6-users wrote: >>> >>>> Hi All, >>>> >>

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: "index" source code?

2019-02-03 Thread ToddAndMargo via perl6-users
Note that they heavily use NQP opcodes, so you shouldn't try and copy them. On Sun, Feb 3, 2019 at 12:35 AM ToddAndMargo via perl6-users wrote: Hi All, Was the subroutine "index" written Perl6? If so, where can I view the source code? Many thanks, -T Thank you! The nqp op codes do seem way over my head. :'(

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 = "s

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 th

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)

"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 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-us...@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 fo

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 th

Re: binary test and position?

2019-02-04 Thread ToddAndMargo via perl6-users
Seq ) { my List $Matcher = $SubBuf.List; my Int $Elems = $Matcher.elems; return $Buffer.rotor($Elems => 1- $Elems).grep(* eqv $Matcher, :k); } } On Sat, Feb 2, 2019 at 10:05 PM ToddAndMargo via perl6-users wrote: On 2/2/19 6:09 AM, Brad Gilbert wrote:

Re: binary test and position?

2019-02-05 Thread ToddAndMargo via perl6-users
ample. That is not how Bufs are stored in Perl6 at all. They are declared with `is repr('VMArray')` which basically means they are stored as C arrays. On Tue, Feb 5, 2019 at 1:47 AM ToddAndMargo via perl6-users wrote: On 2/2/19 9:29 PM, Brad Gilbert wrote: Subs do not need to have a `r

Re: binary test and position?

2019-02-05 Thread ToddAndMargo via perl6-users
On 2/5/19 8:26 AM, Curt Tilmes wrote: If you have glibc (probably yes for Linux or Mac, probably no for Windows), you can call memmem(): use NativeCall; sub memmem(Blob $haystack, size_t $haystacklen,            Blob $needle,   size_t $needlelen --> Pointer) is native {} sub buf-index(Blob

Re: reassigning values to variables question

2019-02-05 Thread ToddAndMargo via perl6-users
On Sun, Feb 3, 2019 at 9:36 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: 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 th

split and nils?

2019-02-05 Thread ToddAndMargo via perl6-users
Hi All, What is with the starting ending Nils? There are only four elements, why now six? And how to I correct this? $ p6 'my Str $x="abcd"; for split( "",@$x ).kv -> $i,$j { say "Index <$i> = <$j> = ord <" ~ ord($j) ~ ">";}' Use of Nil in string context in block at -e line 1 Ind

VS_VERSION_INFO?

2019-02-05 Thread ToddAndMargo via perl6-users
Hi All, Anyone know how to find the pointer to VS_VERSION_INFO in a Windows .exe file? Supposedly, this link tells you but .. https://docs.microsoft.com/en-us/windows/desktop/debug/pe-format#section-table-section-headers Many thanks, -T

Re: reassigning values to variables question

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/5/19 8:34 PM, ToddAndMargo via perl6-users wrote: On Sun, Feb 3, 2019 at 9:36 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote:     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,

Re: reassigning values to variables question

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/5/19 11:56 PM, ToddAndMargo via perl6-users wrote: On 2/5/19 8:34 PM, ToddAndMargo via perl6-users wrote: On Sun, Feb 3, 2019 at 9:36 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote:     Hi All,     If I have a variable of type Buf which 1000 bytes

Re: reassigning values to variables question

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 12:44 AM, ToddAndMargo via perl6-users wrote: On 2/5/19 11:56 PM, ToddAndMargo via perl6-users wrote: On 2/5/19 8:34 PM, ToddAndMargo via perl6-users wrote: On Sun, Feb 3, 2019 at 9:36 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote:     Hi All,   

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
> On Tue, Feb 5, 2019 at 11:05 PM ToddAndMargo via perl6-users > wrote: >> >> Hi All, >> >> What is with the starting ending Nils? There are only four >> elements, why now six? >> >> And how to I correct this? >> >> $ p6

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 5:19 AM, Brad Gilbert wrote: The reason there is a Nil, is you asked for the ord of an empty string. "".ord =:= Nil The reason there are two empty strings is you asked for them. What would be the most practice way of converting a string to and array of characters? $x="abc" goe

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
actice [practical] way of converting a string to and array of characters? $x="abc" goes to @y[0]="a", @y[1]="b", @y[2]="c" On 2/6/19 12:12 PM, Laurent Rosenfeld via perl6-users wrote: Brad told you already: use comb. Le mer. 6 févr. 2019 à 20:57, To

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On 2/6/19 12:58 PM, Patrick R. Michaud wrote: On Wed, Feb 06, 2019 at 12:38:01PM -0800, ToddAndMargo via perl6-users wrote: $ p6 'my Str $x="abcd"; for $x.comb.kv -> $i, $j {say "Index <$i> = <$j> = ord <" ~ ord($j) ~ ">";}' Index

Re: split and nils?

2019-02-06 Thread ToddAndMargo via perl6-users
On Wed, Feb 6, 2019 at 1:02 PM ToddAndMargo via perl6-users mailto:perl6-us...@perl.org>> wrote: On 2/6/19 12:58 PM, Patrick R. Michaud wrote: > On Wed, Feb 06, 2019 at 12:38:01PM -0800, ToddAndMargo via perl6-users wrote: >> $ p6 'my Str $x="abcd&q

  1   2   3   4   5   6   7   8   9   10   >