Re: Raku is removed from Debian

2024-09-08 Thread ToddAndMargo via perl6-users

On 9/8/24 02:14, Dominique Dumont wrote:


And the files used to make these packages cannot be re-used much for official
Debian project because they do not respect Debian packaging policies (the same
policies that make Debian distribution quite solid).


I asked Fedora about the same thing.  Fedora wanted
the source files (srpm).  So I asked nxadm about that and
they answered that they could not due to the way they
compile things.   I know it sounds weird, but it
made sense at the time.



Re: Raku is removed from Debian

2024-09-08 Thread Dominique Dumont
Hi

On Sunday, 8 September 2024 03:28:43 CEST ToddAndMargo via perl6-users wrote:
> Not was you asked, BUT WHEN DOES THAT STOP ME

Fair enough :-)

> Debian is supported over on
> https://github.com/nxadm/rakudo-pkg/releases
> 
> I see a when you click on "show all xxx assets".
> https://github.com/nxadm/rakudo-pkg/releases/download/v2024.08/rakudo-pkg-De
> bian12_2024.08-01_amd64.deb
> 
> I have been using their Fedora release for years.

Well, great. The only problem is that these packages are not easy to discover 
for people wanting to try Raku.

And the files used to make these packages cannot be re-used much for official 
Debian project because they do not respect Debian packaging policies (the same 
policies that make Debian distribution quite solid).

Anyway, thanks the pointer 

All the best





Re: Raku is removed from Debian

2024-09-07 Thread ToddAndMargo via perl6-users

On 9/4/24 03:25, Dominique Dumont wrote:

Hello

As I feared, raku was removed from Debian testing. Which means that raku will
be missing in next Debian release, and probably from Ubuntu and Mint.

What led to this situation ?
- the last version of raku provided in Debian is 2022.12 and it does not
compile with GCC14. This is a critical bug which triggered the removal of
moarvm and all its reverse dependencies, i.e. nqp, raku and all raku modules.

Dod (he-him)


Hi Dominique,

Not was you asked, BUT WHEN DOES THAT STOP ME

Debian is supported over on
https://github.com/nxadm/rakudo-pkg/releases

I see a when you click on "show all xxx assets".
https://github.com/nxadm/rakudo-pkg/releases/download/v2024.08/rakudo-pkg-Debian12_2024.08-01_amd64.deb

I have been using their Fedora release for years.

-T  (T/Todd/Dude/His Resplendence)



--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~



Re: Raku is removed from Debian

2024-09-04 Thread Dominique Dumont
On Wednesday, 4 September 2024 18:23:25 CEST Dominique Dumont wrote:
> Sure, I will help you get started. Feel free to ask questions on debian-
> mentors mailing list. I'm sure a lot of Debian people will also help out.

I forgot the link to debian-mentors list: 

 https://lists.debian.org/debian-mentors

All the best






Re: Raku is removed from Debian

2024-09-04 Thread Dominique Dumont
On Wednesday, 4 September 2024 13:28:20 CEST Will Coleda wrote:
> As someone who managed a macport aeons ago, any chance you could hold my
> hand through the process of getting the package updated? I'm happy to make
> the code/config changes and do the actual submittal.

Sure, I will help you get started. Feel free to ask questions on debian-
mentors mailing list. I'm sure a lot of Debian people will also help out.

All the best





Re: Raku is removed from Debian

2024-09-04 Thread Dominique Dumont
Hi

On Wednesday, 4 September 2024 17:49:28 CEST Timo Paulssen via perl6-users 
wrote:
> Coke and myself have signed up to salsa with the user names timotimo and
> coke respectively.

Since you're not Debian developer (yet ? 😉), it's customary to guest a login 
ending with -guest.

I've accepted too fast your request as timotimo and then removed it. Please 
send a new request as timotimo-guest.

> We* would appreciate if you give us access to the perl6-team group and
> what else we need to start working on the packages. 

Will do as soon as the login names are fine.

> For example, I have
> a patch that should make moarvm build again, and I would like to get the
> salsa ci/cd pipeline configured for at least moarvm as well.

ok, that's a first step before an upgrade to a more recent version.

> We can probably find out what the first few steps are going to be from
> the "getting started contributing to debian" documentation and asking on
> #debian-mentors. If you want to point some stuff out or give us a little
> tour right away, that would also be cool of course.

Sure, I will send you links. For instance, there's a lot of 'debian/
README.source' files in the repo so this should get you started.

E.g. https://salsa.debian.org/perl6-team/moarvm/-/blob/master/debian/
README.source.org?ref_type=heads

> Feel free to reach out on IRC if you have the time, or via mail is fine
> as well, of course.

I prefer mail, I often miss IRC notifications.

> Hopefully we can have some packages for you to "sponsor" soon :)

That would be great, I would hate to see all my work forgotten.

All the best




Re: Raku is removed from Debian

2024-09-04 Thread Timo Paulssen via perl6-users

Hi Dominique,

first of all, thank you for bringing this to our attention, and all the 
time you've spent on maintaining the Raku packages and debhelpers!


Coke and myself have signed up to salsa with the user names timotimo and 
coke respectively.


We* would appreciate if you give us access to the perl6-team group and 
what else we need to start working on the packages. For example, I have 
a patch that should make moarvm build again, and I would like to get the 
salsa ci/cd pipeline configured for at least moarvm as well.


We can probably find out what the first few steps are going to be from 
the "getting started contributing to debian" documentation and asking on 
#debian-mentors. If you want to point some stuff out or give us a little 
tour right away, that would also be cool of course.


Feel free to reach out on IRC if you have the time, or via mail is fine 
as well, of course.


Hopefully we can have some packages for you to "sponsor" soon :)

Kind Regards
  - Timo

* I can only speak for myself, I'm just assuming Will is fine with my 
claims / suggestions




Re: Raku is removed from Debian

2024-09-04 Thread Will Coleda
Dominique - I've registered my email on the mentor site as a placeholder,
at least.

I assume this is something that with a little help, anyone who compiles
rakudo regularly would be able to get a new release packaged at least a few
times a year.

As someone who managed a macport aeons ago, any chance you could hold my
hand through the process of getting the package updated? I'm happy to make
the code/config changes and do the actual submittal.

On Wed, Sep 4, 2024 at 6:31 AM Dominique Dumont  wrote:

> On Wednesday, 4 September 2024 12:25:21 CEST Dominique Dumont wrote:
> > Hello
> >
> > As I feared, raku was removed from Debian testing. Which means that raku
> > will be missing in next Debian release, and probably from Ubuntu and
> Mint.
> >
> > What led to this situation ?
> > - the last version of raku provided in Debian is 2022.12 and it does not
> > compile with GCC14. This is a critical bug which triggered the removal of
> > moarvm and all its reverse dependencies, i.e. nqp, raku and all raku
> > modules.
>
> Sorry, I hit send by accident.
>
> To revert this removal, Raku needs a volunteer (or many) to take over
> packaging raku and its dependencies. I'm fine with helping these people to
> ramp
> up on packaging Raku for Debian.
>
> See https://mentors.debian.net/ for details on how to package for Debian.
>
> If nobody steps up, raku will eventually be removed from unstable. Once
> that
> point is reached, getting raku back in Debian will be more difficult.
>
> All the best
>
> Dod (he/him)
>
>
>
>


Re: Raku is removed from Debian

2024-09-04 Thread Dominique Dumont
On Wednesday, 4 September 2024 12:25:21 CEST Dominique Dumont wrote:
> Hello
> 
> As I feared, raku was removed from Debian testing. Which means that raku
> will be missing in next Debian release, and probably from Ubuntu and Mint.
> 
> What led to this situation ?
> - the last version of raku provided in Debian is 2022.12 and it does not
> compile with GCC14. This is a critical bug which triggered the removal of
> moarvm and all its reverse dependencies, i.e. nqp, raku and all raku
> modules.

Sorry, I hit send by accident.

To revert this removal, Raku needs a volunteer (or many) to take over 
packaging raku and its dependencies. I'm fine with helping these people to ramp 
up on packaging Raku for Debian.

See https://mentors.debian.net/ for details on how to package for Debian.

If nobody steps up, raku will eventually be removed from unstable. Once that 
point is reached, getting raku back in Debian will be more difficult.

All the best

Dod (he/him)





Re: Problem using precompiled Physics::Measure objects

2024-07-31 Thread Elizabeth Mattijsen
> On 31 Jul 2024, at 14:14, Kevin Pye  wrote:
> We'll keep looking at other ways of defining the objects, but thanks anyway. 
> (And sorry for increasing the RakuAST work needed.)

No worries: what would help is a golf of the problem.  And make that an issue 
in the rakudo repo.



Liz

Re: Problem using precompiled Physics::Measure objects

2024-07-31 Thread Kevin Pye



On Wed, 31 Jul 2024, at 19:20, Elizabeth Mattijsen wrote:
>> On 31 Jul 2024, at 06:10, Kevin Pye  wrote:
>> 
>> I am trying to build a replacement for the existing Physics::Constants 
>> module, but running into problems when loading the pre-compiled version. I 
>> want to use code like:
>> 
>> unit module Physics::Constants;
>> 
>> use Physics::Unit;
>> use Physics::Measure;
>> 
>> constant \avogadro-constant is export(:DEFAULT, :fundamental, 
>> :avogadro-constant) = Measure.new(
>>   value => 6.02214076e+23, 
>>   error => 0, 
>>   units => 'mol⁻¹',
>> );
>> 
>> which compiles and runs quite well. However, when I try to run "mi6 test" 
>> which will precompile and then load the code, I get the following output:
>> 
>> $ mi6 test
>> ===SORRY!=== Error while compiling 
>> /home/kevin/git/Physics-Constants/t/01-basic.rakutest
>> ===SORRY!=== Error while compiling 
>> /home/kevin/git/Physics-Constants/lib/Physics/Constants.rakumod 
>> (Physics::Constants)
>> An exception X::Comp::AdHoc occurred while evaluating a constant:
>> Cannot unbox a P6opaque (NQPMu) type object
>> at /home/kevin/git/Physics-Constants/lib/Physics/Constants.rakumod 
>> (Physics::Constants):6
>> Exception details:
>>   ===SORRY!=== Error while compiling 
>>   Cannot unbox a P6opaque (NQPMu) type object
>>   at line 
>> 
>> at .../Physics-Constants/t/01-basic.rakutest:2
>> t/01-basic.rakutest .. Dubious, test returned 1
>> No subtests run
>> 
>> I am guessing that it can't deserialize the serialized Physics::Measure 
>> object, but I could be quite wrong.
>
> This appears to be an issue with resolving somewhere deep in the 
> bowels.  In RakuAST, the error is slightly more clear:
>
> ===SORRY!===
> Cannot look up attributes in a RakuAST::Resolver type object. Did you 
> forget a '.new'?
>
> I'm pretty sure we won't fix this in the legacy grammar.  I'll be 
> looking at fixing this in RakuAST.  Meanwhile, I would also suggest 
> making this an issue in the Physics::Measure repo 
> https://github.com/librasteve/raku-Physics-Measure so that the author 
> is alerted to this problem, and maybe can figure out what tickles it.

The Physics::Measure author is already aware of the issue.

>
>
>> Any ideas on how to make this work?
>
> Put this in lib/Physics/Constants.rakumod:
> =
> use Physics::Unit;
> use Physics::Measure;
>
> my $avogadro-constant := Measure.new(
>   value => 6.02214076e+23,
>   error => 0,
>   units => 'mol⁻¹',
> );
>
> sub EXPORT {
> Map.new: (:$avogadro-constant)  # must have () to force positional Pair
> }
> =
>
> And then run:
>
> $ raku -Ilib -MConstants -e 'say avogadro-constant'
> 6.02214076e+23mol⁻¹ ±0
>
> In other words: drop the module statement.  The namespace *from* which 
> you export constants, is usually not important.  And use an EXPORT sub 
> (https://docs.raku.org/syntax/sub%20EXPORT) to export whatever values 
> that were created when the mainline of the module runs.
>
> Disadvantages to this approach:
> - you lose the standard capability to selective importing
> - the constants are created at module load time, and not serialized

Unfortunately that won't help much in this case. There are over 300 constants 
planned to be included. Using a separate EXPORT sub decouples the definitions 
and export declarations too much, selective importing will be very useful to 
avoid polluting the namespace of code using the module, and creating hundreds 
of Physics::Measure objects at load time will be simply much too slow. (You 
might get away with it with selective importing and only creating a relatively 
few objects, but without that...)

We'll keep looking at other ways of defining the objects, but thanks anyway. 
(And sorry for increasing the RakuAST work needed.)

Kevin.


Re: Problem using precompiled Physics::Measure objects

2024-07-31 Thread Elizabeth Mattijsen
> On 31 Jul 2024, at 06:10, Kevin Pye  wrote:
> 
> I am trying to build a replacement for the existing Physics::Constants 
> module, but running into problems when loading the pre-compiled version. I 
> want to use code like:
> 
> unit module Physics::Constants;
> 
> use Physics::Unit;
> use Physics::Measure;
> 
> constant \avogadro-constant is export(:DEFAULT, :fundamental, 
> :avogadro-constant) = Measure.new(
>   value => 6.02214076e+23, 
>   error => 0, 
>   units => 'mol⁻¹',
> );
> 
> which compiles and runs quite well. However, when I try to run "mi6 test" 
> which will precompile and then load the code, I get the following output:
> 
> $ mi6 test
> ===SORRY!=== Error while compiling 
> /home/kevin/git/Physics-Constants/t/01-basic.rakutest
> ===SORRY!=== Error while compiling 
> /home/kevin/git/Physics-Constants/lib/Physics/Constants.rakumod 
> (Physics::Constants)
> An exception X::Comp::AdHoc occurred while evaluating a constant:
> Cannot unbox a P6opaque (NQPMu) type object
> at /home/kevin/git/Physics-Constants/lib/Physics/Constants.rakumod 
> (Physics::Constants):6
> Exception details:
>   ===SORRY!=== Error while compiling 
>   Cannot unbox a P6opaque (NQPMu) type object
>   at line 
> 
> at .../Physics-Constants/t/01-basic.rakutest:2
> t/01-basic.rakutest .. Dubious, test returned 1
> No subtests run
> 
> I am guessing that it can't deserialize the serialized Physics::Measure 
> object, but I could be quite wrong.

This appears to be an issue with resolving somewhere deep in the bowels.  In 
RakuAST, the error is slightly more clear:

===SORRY!===
Cannot look up attributes in a RakuAST::Resolver type object. Did you forget a 
'.new'?

I'm pretty sure we won't fix this in the legacy grammar.  I'll be looking at 
fixing this in RakuAST.  Meanwhile, I would also suggest making this an issue 
in the Physics::Measure repo https://github.com/librasteve/raku-Physics-Measure 
so that the author is alerted to this problem, and maybe can figure out what 
tickles it.


> Any ideas on how to make this work?

Put this in lib/Physics/Constants.rakumod:
=
use Physics::Unit;
use Physics::Measure;

my $avogadro-constant := Measure.new(
  value => 6.02214076e+23,
  error => 0,
  units => 'mol⁻¹',
);

sub EXPORT {
Map.new: (:$avogadro-constant)  # must have () to force positional Pair
}
=

And then run:

$ raku -Ilib -MConstants -e 'say avogadro-constant'
6.02214076e+23mol⁻¹ ±0

In other words: drop the module statement.  The namespace *from* which you 
export constants, is usually not important.  And use an EXPORT sub 
(https://docs.raku.org/syntax/sub%20EXPORT) to export whatever values that were 
created when the mainline of the module runs.

Disadvantages to this approach:
- you lose the standard capability to selective importing
- the constants are created at module load time, and not serialized


HTH,

Liz

Re: PostgreSQL: Raku as a "trusted" language?

2024-06-28 Thread Darren Duncan

On 2024-05-15 12:08 p.m., William Michels via perl6-users wrote:
I'm wondering if the "trusted" moniker is conferred when a (specified/bespoke) 
language version sufficiently sanitizes input?


What you're talking about here and similar has no affect on trusted vs not.

Trusted and untrusted are determined based on fundamental structural differences 
of the language implementation.


A trusted language is a fully isolated environment that fundamentally has only 
the core language features to write routines that take arguments, return 
results, and read from or write to database tables, basically what you can do 
with ordinary SQL stored procedures but with a different syntax.


A trusted language can not access anything outside the database in any manner, 
such as access the file system or run other programs or access the network or 
whatever, since generally this is where the biggest security concerns are.  If 
you want to do any of those things, that is what the "untrusted" version is for.


The idea is if you stick to the more restricted capabilities of a "trusted" 
language, users can be much more confident they are avoiding risks, and they 
would be more comfortable using it.


-- Darren Duncan



Re: PostgreSQL: Raku as a "trusted" language?

2024-05-15 Thread JJ Merelo
El mié, 15 may 2024 a las 21:08, William Michels ()
escribió:

> Thanks for your response, JJ.
>
> I'm wondering if the "trusted" moniker is conferred when a
> (specified/bespoke) language version sufficiently sanitizes input?
>

Not only that, also output to the filesystem and network.

>
> If so, your Unicode::Security module would seem to be right on the mark:
>
> https://raku.land/zef:jjmerelo/Unicode::Security
>
> https://github.com/JJ/raku-unicode-security
>

:-) It might help, I guess. But that would be just something to detect
possibly insecure strings.

Cheers

JJ


Re: PostgreSQL: Raku as a "trusted" language?

2024-05-15 Thread William Michels via perl6-users
Thanks for your response, JJ.

I'm wondering if the "trusted" moniker is conferred when a (specified/bespoke) 
language version sufficiently sanitizes input?

If so, your Unicode::Security module would seem to be right on the mark:

https://raku.land/zef:jjmerelo/Unicode::Security

https://github.com/JJ/raku-unicode-security

Best, Bill.


> On Apr 17, 2024, at 12:29, JJ Merelo  wrote:
> 
> From what I'm seeing, my impression is that you need to create a specific 
> version, possibly with Pg bindings, to become either trusted or untrusted; 
> there's no Trusted "node" (or bun, for that matter), but a "v8js" version of 
> JavaScript. 
> 
> Any PL (procedural language) version of the language would be used to create 
> embedded procedures. The user base for such a thing does not guarantee the 
> effort needed to create such a version of Rakudo (which, from what I can 
> tell, would need to be refactored at the NPQ level, since "trusted" versions 
> can't, for instance, access the filesystem)
> 
> El mié, 17 abr 2024 a las 21:04, William Michels via perl6-users 
> (mailto:perl6-users@perl.org>>) escribió:
>> Hi, 
>> 
>> Thinking about which database to use with Raku, I started following a 
>> question from StackOverflow--here:
>> 
>> "list of PostgreSQL trusted languages?"
>> https://dba.stackexchange.com/questions/156631/list-of-postgresql-trusted-languages
>> 
>> From that page I learned that there are both "trusted" and "untrusted" modes 
>> for use of Perl with PostgreSQL:
>> 
>> "45.5. Trusted and Untrusted PL/Perl"
>> https://www.postgresql.org/docs/current/plperl-trusted.html
>> 
>> Which led me to a matrix of programming languages and trust modes:
>> 
>> "PL Matrix"
>> https://wiki.postgresql.org/wiki/PL_Matrix
>> 
>> On the final PL link above, Raku doesn't appear at all--so the questions 
>> arise:
>> 
>> 1. How can the Raku community get Raku added on the "PL Matrix" page?
>> 
>> 2. How can the Raku community get Raku accepted as a "trusted" PL for use 
>> with PostgreSQL?
>> 
>> 
>> Thx,
>> 
>> Bill.
>> 
> 
> 
> -- 
> JJ



Re: Array remove duplicates question

2024-05-06 Thread ToddAndMargo via perl6-users

On 5/6/24 05:45, yary wrote:

I thought you wanted them sorted also?

[1] > (8,7,6,7,5,4,2,1).unique
(8 7 6 5 4 2 1)
[2] > (8,7,6,7,5,4,2,1).unique.sort
(1 2 4 5 6 7 8)


-y


Hi Yary,

Not in this instance.  But the the command is
really sweet.  Thank you!

This time I am going the extract IP addresses from
a firewall log of hackers attacking my customer's
firewalls with a "Brute Force Attack", strip the
source port, remove the bazillions of duplicates,
add the location (city and country) of the
attacker, format an output such that their firewalls
can add them to the group deny list.  Does not matter
if the are sorted.

I will definitely use  your .sort if the future.
At least I will not have to make any API calls
this time.

Its a living.

-T

Oh ya, and install Multi Factor Authentication
too.  But no Raku needed for that.




Re: Array remove duplicates question

2024-05-06 Thread yary
I thought you wanted them sorted also?

[1] > (8,7,6,7,5,4,2,1).unique
(8 7 6 5 4 2 1)
[2] > (8,7,6,7,5,4,2,1).unique.sort
(1 2 4 5 6 7 8)


-y


On Mon, May 6, 2024 at 6:15 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 5/6/24 03:07, ToddAndMargo via perl6-users wrote:
> >
> >>> On 6 May 2024, at 04:35, ToddAndMargo via perl6-users
> >>>  wrote:
> >>>
> >>> Hi All,
> >>>
> >>> I have thought of how to do it and pretty sure
> >>> it would work, but just in case Raku have one
> >>> of those sweet utilities, does Raku have a
> >>> utility that will take an array and remove all
> >>> the duplicates and rearrange the cells back
> >>> in order?
> >>>
> >>> Many thanks,
> >>> -T
> >
> > On 5/6/24 01:59, Elizabeth Mattijsen wrote:
> >  > $ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
> >  > [1 2 3 6 7 8]
> >  >
> >  > https://docs.raku.org/type/Any#method_unique
> >  >
> >
> > I knew there had to be something!   Thank you!
>
> My keeper:  perl6.array.duplicates.unique.txt
>
>
> Raku (perl6): how to remove duplicates from an array:
>
> Use `unique` and `.=`
>
> For example:
>
> $ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
> [1 2 3 6 7 8]
>
> $ raku -e 'my @a = "abc","DEF","abc","jkl",1,2,8; @a .= unique; say @a'
> [abc DEF jkl 1 2 8]
>
> $ raku -e 'my @a = "abc","DEF","abc","jkl",1; @a .= unique; say @a'
> [abc DEF jkl 1]
>
> $ raku -e 'my @a = "abc","DEF","abc","jkl",1,8,1,2,8; @a .= unique; say @a'
> [abc DEF jkl 1 8 2]
>
>
>


Re: Array remove duplicates question

2024-05-06 Thread ToddAndMargo via perl6-users

On 5/6/24 03:07, ToddAndMargo via perl6-users wrote:


On 6 May 2024, at 04:35, ToddAndMargo via perl6-users 
 wrote:


Hi All,

I have thought of how to do it and pretty sure
it would work, but just in case Raku have one
of those sweet utilities, does Raku have a
utility that will take an array and remove all
the duplicates and rearrange the cells back
in order?

Many thanks,
-T


On 5/6/24 01:59, Elizabeth Mattijsen wrote:
 > $ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
 > [1 2 3 6 7 8]
 >
 > https://docs.raku.org/type/Any#method_unique
 >

I knew there had to be something!   Thank you!


My keeper:  perl6.array.duplicates.unique.txt


Raku (perl6): how to remove duplicates from an array:

Use `unique` and `.=`

For example:

$ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
[1 2 3 6 7 8]

$ raku -e 'my @a = "abc","DEF","abc","jkl",1,2,8; @a .= unique; say @a'
[abc DEF jkl 1 2 8]

$ raku -e 'my @a = "abc","DEF","abc","jkl",1; @a .= unique; say @a'
[abc DEF jkl 1]

$ raku -e 'my @a = "abc","DEF","abc","jkl",1,8,1,2,8; @a .= unique; say @a'
[abc DEF jkl 1 8 2]




Re: Array remove duplicates question

2024-05-06 Thread ToddAndMargo via perl6-users




On 6 May 2024, at 04:35, ToddAndMargo via perl6-users  
wrote:

Hi All,

I have thought of how to do it and pretty sure
it would work, but just in case Raku have one
of those sweet utilities, does Raku have a
utility that will take an array and remove all
the duplicates and rearrange the cells back
in order?

Many thanks,
-T


On 5/6/24 01:59, Elizabeth Mattijsen wrote:
> $ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
> [1 2 3 6 7 8]
>
> https://docs.raku.org/type/Any#method_unique
>

I knew there had to be something!   Thank you!



Re: Array remove duplicates question

2024-05-06 Thread Elizabeth Mattijsen
$ raku -e 'my @a = 1,2,3,6,7,1,2,8; @a .= unique; say @a'
[1 2 3 6 7 8]

https://docs.raku.org/type/Any#method_unique

> On 6 May 2024, at 04:35, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> I have thought of how to do it and pretty sure
> it would work, but just in case Raku have one
> of those sweet utilities, does Raku have a
> utility that will take an array and remove all
> the duplicates and rearrange the cells back
> in order?
> 
> Many thanks,
> -T
> 
> 



Re: Need regex ^? help

2024-05-06 Thread ToddAndMargo via perl6-users

This is what I have so far.

my $x="  1.2.3.4:12345   "; $x = $x.trim; $x~~s/(.*'.') 
.*/$0$(Q[0/24])/; say "<$x>";

<1.2.3.0/24>

It works. Is there a way to petty it up with ^ and $   ?




Re: Need regex ^? help

2024-04-29 Thread ToddAndMargo via perl6-users

On 4/29/24 17:57, Patrick R. Michaud wrote:

Perhaps not really what you're intending, but here's how I'd start:

 $ raku -e 'my $x="1.2.3.4"; $x ~~ s!\d+$!0/24!; say $x;'
 1.2.3.0/24

The pattern part of the substitution matches all of the digits at the end of the string 
(\d+$), then replaces them with the string "0/24".  Everything prior to those 
digits is left alone.

On Mon, Apr 29, 2024 at 05:45:49PM -0700, ToddAndMargo via perl6-users wrote:

On 4/29/24 17:42, ToddAndMargo via perl6-users wrote:

Hi All,

I thought I understood ^ and ? used in a regex'es,
but I don't.

^ means from the beginning and ? from the end.


I think you mean "$" here instead of "?".

Pm



Oh I did figure it out another way.  I am trying to
get a working example of ^ and $ for my Redex
keeper file


Re: Need regex ^? help

2024-04-29 Thread Patrick R. Michaud
Perhaps not really what you're intending, but here's how I'd start:

$ raku -e 'my $x="1.2.3.4"; $x ~~ s!\d+$!0/24!; say $x;'
1.2.3.0/24

The pattern part of the substitution matches all of the digits at the end of 
the string (\d+$), then replaces them with the string "0/24".  Everything prior 
to those digits is left alone.

On Mon, Apr 29, 2024 at 05:45:49PM -0700, ToddAndMargo via perl6-users wrote:
> On 4/29/24 17:42, ToddAndMargo via perl6-users wrote:
> > Hi All,
> > 
> > I thought I understood ^ and ? used in a regex'es,
> > but I don't.
> > 
> > ^ means from the beginning and ? from the end.

I think you mean "$" here instead of "?".

Pm


Re: Need regex ^? help

2024-04-29 Thread ToddAndMargo via perl6-users

On 4/29/24 17:42, ToddAndMargo via perl6-users wrote:

Hi All,

I thought I understood ^ and ? used in a regex'es,
but I don't.

^ means from the beginning and ? from the end.

I am trying to put together an example
of how to use them:

I have

    1.2.3.4

I want
    1.2.3.0/24

So Far I have (not working):

    raku -e 'my $x="1.2.3.4"; $x~~s/ (.*) $(Q[.]) /$0Q[0/24]/; say $x;'

How do I do this with ^ and $  ?

Many thanks,
-T



raku -e 'my $x="1.2.3.4"; $x~~s/ (.*) $(Q[.]) /$0$(Q[0.24])/; say $x;'
1.2.30.244





Re: Is irc.libera.chat down?

2024-04-19 Thread ToddAndMargo via perl6-users

A sex, 19-04-2024 às 03:09 -0700, Todd Chester via perl6-users
escreveu:

A sex, 19-04-2024 às 02:36 -0700, Todd Chester via perl6-users
escreveu:

Hi All,

Is
  https://kiwiirc.com/nextclient/irc.libera.chat/#raku
down?

-T




On 4/19/24 03:03, David Santiago wrote:
  >
  > It works for me.
  >
  > Regards,
  > David
  >

Hi David,

The circle just goes round and round and after
a while, it times out.

I tried both Firefox and Brave Browser.

I wonder if I got "quieted" or banned.   Is there
a way to tell?

-T


On 4/19/24 03:56, David Santiago wrote:
>
> Do you have any adblocker or any extension that blocks js? If so try to
> disable it.
>
> You can also use a dedicated client instead of the browser:
>
> www.mirc.com (for windows) or https://hexchat.github.io/ (for windows
> and linux).
>
>
> Regards,
> David Santiago

Hi David,

Did not help.  It is my username that is banned.

If memory serves, about a year ago, I logged into
it to ask a question  and someone screeded all over
me with a bunch of very creative insults.  I tried
to talk with him but got no answer back.  I did not
think much of it at the time.  I post on usenet a lot
and you develop a pretty thick skin.  After that
I was never able to get anyone to answer me.

So it is what it is.  I will jut use a different
username.  Maybe the libeler will be in a better
mood next time.

-T






Re: Is irc.libera.chat down?

2024-04-19 Thread David Santiago


Do you have any adblocker or any extension that blocks js? If so try to
disable it.

You can also use a dedicated client instead of the browser: 

www.mirc.com (for windows) or https://hexchat.github.io/ (for windows
and linux).


Regards,
David Santiago



A sex, 19-04-2024 às 03:09 -0700, Todd Chester via perl6-users
escreveu:
> > A sex, 19-04-2024 às 02:36 -0700, Todd Chester via perl6-users
> > escreveu:
> > > Hi All,
> > > 
> > > Is
> > >  https://kiwiirc.com/nextclient/irc.libera.chat/#raku
> > > down?
> > > 
> > > -T
> > 
> 
> On 4/19/24 03:03, David Santiago wrote:
>  >
>  > It works for me.
>  >
>  > Regards,
>  > David
>  >
> 
> Hi David,
> 
> The circle just goes round and round and after
> a while, it times out.
> 
> I tried both Firefox and Brave Browser.
> 
> I wonder if I got "quieted" or banned.   Is there
> a way to tell?
> 
> -T



Re: Is irc.libera.chat down?

2024-04-19 Thread Todd Chester via perl6-users




On 4/19/24 03:09, Todd Chester via perl6-users wrote:

A sex, 19-04-2024 às 02:36 -0700, Todd Chester via perl6-users
escreveu:

Hi All,

Is
 https://kiwiirc.com/nextclient/irc.libera.chat/#raku
down?

-T




On 4/19/24 03:03, David Santiago wrote:
 >
 > It works for me.
 >
 > Regards,
 > David
 >

Hi David,

The circle just goes round and round and after
a while, it times out.

I tried both Firefox and Brave Browser.

I wonder if I got "quieted" or banned.   Is there
a way to tell?

-T


I changed my username and got immediately in.
Wonder what it does not like about my user name?



Re: Is irc.libera.chat down?

2024-04-19 Thread Todd Chester via perl6-users

A sex, 19-04-2024 às 02:36 -0700, Todd Chester via perl6-users
escreveu:

Hi All,

Is
     https://kiwiirc.com/nextclient/irc.libera.chat/#raku
down?

-T




On 4/19/24 03:03, David Santiago wrote:
>
> It works for me.
>
> Regards,
> David
>

Hi David,

The circle just goes round and round and after
a while, it times out.

I tried both Firefox and Brave Browser.

I wonder if I got "quieted" or banned.   Is there
a way to tell?

-T


Re: Is irc.libera.chat down?

2024-04-19 Thread David Santiago


It works for me.

Regards,
David


A sex, 19-04-2024 às 02:36 -0700, Todd Chester via perl6-users
escreveu:
> Hi All,
> 
> Is
>     https://kiwiirc.com/nextclient/irc.libera.chat/#raku
> down?
> 
> -T



Re: need native call help

2024-04-19 Thread Todd Chester via perl6-users




On 4/18/24 04:50, yary wrote:
I did a lot of very deep windows programming in my previous job and 
reminding me that I would always use the 8.3 short name for file 
operations! dir /x will get it for you. Must be API called for it also. 
Probably only works on local volumes not network rounded ones. Just a guess.


AreShortNamesEnabled function (fileapi.h)
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-areshortnamesenabled

and

GetShortPathNameW function (fileapi.h)
https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-getshortpathnamew

The silly "W" at the above means you have to convert your
string to UTF16.  If yo have a "A" at the end, you can
just use UTF8.  I have modules for to convert both the them.



I've run into problems on some unix shells with maximum command-line 
lengths.


-y



Hi Yary,

The 64 thousand dollar questions is should
the programming language make allowances for
the "quirks" of an operating system, such as the
260 file limit DeleteFileA, and just presume the
user of the programming language has no business
programming for the particular operating system
if he does not already know the quirks or should
the programming language make allowances?

As for me, when I throw unlink at a file, I expect it
to work or at least be told why not.  So, I think
allowances show be made.

In my DeleteFileA module, I obviously wanted it
to just work, quirks or no quirks, so I could just
go about deleting what I want without having
to be a genius at the operating system and
wasting hours troubleshooting things that don't work
as expected.

In an "ideal world", I never have to goof around
with API calls, unless I was shooting
for something really weird.

Your take?
-T


Re: need native call help

2024-04-18 Thread yary
I did a lot of very deep windows programming in my previous job and
reminding me that I would always use the 8.3 short name for file
operations! dir /x will get it for you. Must be API called for it also.
Probably only works on local volumes not network rounded ones. Just a guess.

I've run into problems on some unix shells with maximum command-line
lengths.

-y


On Wed, 17 Apr 2024 at 11:58 PM, ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 4/17/24 19:10, William Michels via perl6-users wrote:
> > Hi Todd,
> >
> > Here are a few U&L StackExchange answers that I wrote using Raku's
> `unlink`:
> >
> >
> https://unix.stackexchange.com/questions/459521/how-to-truncate-file-to-maximum-number-of-characters-not-bytes/751267#751267
> >
> >
> https://unix.stackexchange.com/questions/749558/remove-exact-line-from-file-if-present-leave-the-rest-of-lines-error-handling/749581#749581
> >
> > (Suggestions welcome).
>
>
> Hi William,
>
> unlink($_) if $bak.IO:e & $bak.IO:f;
>
> Interesting!  Thank you.
>
> The problem is that you can not implicitly trust
> the file operations when programming on the kluge.
> Linux, no problem.
>
> I wish I had more Linux customers, but I do not.
>
> -T
>
> I do not know if you are, but I just append .tmp or .bak on to the name
> of my program.   I have never used Kernel32::GetTempTileNameA.
>
>
> https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea
>


Re: need native call help

2024-04-17 Thread ToddAndMargo via perl6-users

On 4/17/24 19:10, William Michels via perl6-users wrote:

Hi Todd,

Here are a few U&L StackExchange answers that I wrote using Raku's `unlink`:

https://unix.stackexchange.com/questions/459521/how-to-truncate-file-to-maximum-number-of-characters-not-bytes/751267#751267

https://unix.stackexchange.com/questions/749558/remove-exact-line-from-file-if-present-leave-the-rest-of-lines-error-handling/749581#749581

(Suggestions welcome).



Hi William,

unlink($_) if $bak.IO:e & $bak.IO:f;

Interesting!  Thank you.

The problem is that you can not implicitly trust
the file operations when programming on the kluge.
Linux, no problem.

I wish I had more Linux customers, but I do not.

-T

I do not know if you are, but I just append .tmp or .bak on to the name 
of my program.   I have never used Kernel32::GetTempTileNameA.


https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-gettempfilenamea


Re: need native call help

2024-04-17 Thread William Michels via perl6-users
Hi Todd, 

Here are a few U&L StackExchange answers that I wrote using Raku's `unlink`:

https://unix.stackexchange.com/questions/459521/how-to-truncate-file-to-maximum-number-of-characters-not-bytes/751267#751267

https://unix.stackexchange.com/questions/749558/remove-exact-line-from-file-if-present-leave-the-rest-of-lines-error-handling/749581#749581

(Suggestions welcome).

HTH, Bill

> On Apr 17, 2024, at 17:14, ToddAndMargo via perl6-users 
>  wrote:
> 
> On 4/17/24 05:52, yary wrote:
>> From unlink's documentation:
>> If the file to be deleted does not exist, the routine treats it as success.
>> So trying to delete a file that isn't there, doesn't have an error, which is 
>> kind of neat, but that is a difference from native delete.
>> -y
> 
> Hi Yary,
> 
> Not to beat a dead horse, but when does that stop me!
> 
> 
> In Windows, if the filename/path exceeds 260 characters
> (MAX_PATH), unlink will think that the file does not
> exist and will let you blissfully think it has been removed,
> when in reality, it is still there.
> 
> -T



Re: need native call help

2024-04-17 Thread ToddAndMargo via perl6-users

On 4/17/24 05:52, yary wrote:

 From unlink's documentation:

If the file to be deleted does not exist, the routine treats it as success.

So trying to delete a file that isn't there, doesn't have an error, 
which is kind of neat, but that is a difference from native delete.


-y


Hi Yary,

Not to beat a dead horse, but when does that stop me!


In Windows, if the filename/path exceeds 260 characters
(MAX_PATH), unlink will think that the file does not
exist and will let you blissfully think it has been removed,
when in reality, it is still there.

-T


Re: need native call help

2024-04-17 Thread ToddAndMargo via perl6-users

On 4/17/24 05:52, yary wrote:

 From unlink's documentation:

If the file to be deleted does not exist, the routine treats it as success.

So trying to delete a file that isn't there, doesn't have an error, 
which is kind of neat, but that is a difference from native delete.


-y



Hi Yary,

Not neat at all.  And that would be a bug that need
to be fixed.  I spend hours trying to troubleshoot
why I could not delete a file.

1) it should return "File not Found"

and

2) it should return "MAX_PATH exceed in file name"
if that is the case and `\\?\` has not been prepended.
And if such, recommend adding `\\?\`.  Or just
add it automatically as my ApiDeleteFile module
does.


This is Windows we are dealing with after all.

Oh look how it is done in Linux when deleting a
non-existent file:

$ rm abc.txt ; echo $?
rm: cannot remove 'abc.txt': No such file or directory
1

The "No such file or directory" is self explanatory.

The "1" from the echo of "$?" means the command failed,
unlike the no error return from Raku's unlink.  Unlink
need to be fixed.

-T






Re: need native call help

2024-04-17 Thread ToddAndMargo via perl6-users

On 4/17/24 05:50, yary wrote:
What does the windows native delete do which you need, that raku's 
unlink doesn't have?


without unlink $FileName { say "Could not delete $FileName:", 
.exception.message };


-y


Hi Yary,

This is Windows we are dealing with.  It is a kluge.
I have had unlink fail and could not figure out why.

DeleteFileA has wonderful error reporting, well
for Windows.  And you can always count on it doing
things right.  Well, again, maybe..

What caused me to do all this was my inability to delete
the following from the command shell, powershell, and
(Raku) unlink.  But I could delete from Windows Explorer.
I kept getting told the command could not find
the file.   H!

D:\MyDocsBackup\backup2\Mozilla 2024-03-26 16;10;20 
(Full)\Firefox\Profiles\pj0elosu.default-release\storage\default\https+++505991220932649.webpush.freshchat.com^partitionKey=%%28https%%2Cbid13.com%%29\cache\morgue\114\{7cccd5e9-a7aa-4349-a2e9-569baf007272}.final


I had originally thought that the issue was the "weird" characters.
All my attempts to escape the failed.  So out of desperation,
I switched to DeleteFileA.

On DeleteFileA's web page was the give away:

'Tip  Starting with Windows 10, Version 1607, you can
opt-in to remove the MAX_PATH limitation without
prepending "\\?\"'

And I did not realize this a first, but a thorough reading
of the web page and I finally understood.  The file I
was trying to delete was 265 characters long and the
limit (MAX_PATH) was 260.  The commands I was trying
were lopping off five of the characters.  And the commands
did not tell me I had exceeded MAX_PATH.  (This is M$ we
are dealing with after all.)

Now you all that live sheltered lives with Linux, this would
not be an issue.  But the kluge, it is.  You can have to
different max lengths and you have to know when and when
not to prepend.  I am sorry, but what poor programming
on M$'s part.  (Prepending works on shorter files, but
takes longer to process and sometimes coughs.)

You will notice my modules a few things:

1) if the length of the path/name exceeds MAX_PATH and the
path/name does not include \\?\`, then I prepend it.

2) if DeleteFileA return pass, I send back "OK" in the
string.  If not, I send back the error message from
Kernel32::GetLastError" (returns a number) and
Kernel32::WinFormatMessage (translates the error
number to text).

So now I have a powerful tool in addition to unlink in my
tool box to cope with the kluge.

In Linux, I will use unlink, but in the kluge, I will probably
use my ApiDeleteFile.

It never hurts to have enough tools.

-T

Me wonders why Windows programmers do not tear
all their hair out.




Re: PostgreSQL: Raku as a "trusted" language?

2024-04-17 Thread JJ Merelo
>From what I'm seeing, my impression is that you need to create a specific
version, possibly with Pg bindings, to become either trusted or untrusted;
there's no Trusted "node" (or bun, for that matter), but a "v8js" version
of JavaScript.

Any PL (procedural language) version of the language would be used to
create embedded procedures. The user base for such a thing does not
guarantee the effort needed to create such a version of Rakudo (which, from
what I can tell, would need to be refactored at the NPQ level, since
"trusted" versions can't, for instance, access the filesystem)

El mié, 17 abr 2024 a las 21:04, William Michels via perl6-users (<
perl6-users@perl.org>) escribió:

> Hi,
>
> Thinking about which database to use with Raku, I started following a
> question from StackOverflow--here:
>
> "list of PostgreSQL trusted languages?"
>
> https://dba.stackexchange.com/questions/156631/list-of-postgresql-trusted-languages
>
> From that page I learned that there are both "trusted" and "untrusted"
> modes for use of Perl with PostgreSQL:
>
> "45.5. Trusted and Untrusted PL/Perl"
> https://www.postgresql.org/docs/current/plperl-trusted.html
>
> Which led me to a matrix of programming languages and trust modes:
>
> "PL Matrix"
> https://wiki.postgresql.org/wiki/PL_Matrix
>
> On the final PL link above, Raku doesn't appear at all--so the questions
> arise:
>
> 1. How can the Raku community get Raku added on the "PL Matrix" page?
>
> 2. How can the Raku community get Raku accepted as a "trusted" PL for use
> with PostgreSQL?
>
>
> Thx,
>
> Bill.
>
>

-- 
JJ


Re: need native call help

2024-04-17 Thread yary
>From unlink's documentation:

 If the file to be deleted does not exist, the routine treats it as success.

So trying to delete a file that isn't there, doesn't have an error, which
is kind of neat, but that is a difference from native delete.

-y


On Wed, Apr 17, 2024 at 8:50 AM yary  wrote:

> What does the windows native delete do which you need, that raku's unlink 
> doesn't
> have?
>
> without unlink $FileName { say "Could not delete $FileName:", 
> .exception.message
> };
>
> -y
>
>
> On Wed, Apr 17, 2024 at 2:29 AM ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
>
>> On 4/16/24 23:25, ToddAndMargo via perl6-users wrote:
>> `\\>\` should have been
>> `\\?\`
>>
>>


Re: need native call help

2024-04-17 Thread yary
What does the windows native delete do which you need, that raku's
unlink doesn't
have?

without unlink $FileName { say "Could not delete $FileName:",
.exception.message
};

-y


On Wed, Apr 17, 2024 at 2:29 AM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 4/16/24 23:25, ToddAndMargo via perl6-users wrote:
> `\\>\` should have been
> `\\?\`
>
>


Re: need native call help

2024-04-16 Thread ToddAndMargo via perl6-users

On 4/16/24 23:25, ToddAndMargo via perl6-users wrote:
`\\>\` should have been
`\\?\`



Re: need native call help

2024-04-16 Thread ToddAndMargo via perl6-users

On 4/16/24 20:57, ToddAndMargo via perl6-users wrote:


    $LongName = $FileName;
    if $FileName.chars >= MAX_PATH  { $LongName = Q[\\?\] ~ $FileName; }


What the about is all about is that MAX_PATH, which
limits the file name to 260 characters, can go up to
32,767 wide characters, prepend "\\?\" to the path.

I altered the above line since posting to:

   $LongName = $FileName;
   if $FileName.chars >= MAX_PATH  &&  not $FileName.starts-with( 
Q[\\?] )  {

   $LongName = Q[\\?\] ~ $FileName;
   }


in case I forget that my module prepends the `\\>\` if
I exceed MAX_PATH




Re: need native call help

2024-04-16 Thread ToddAndMargo via perl6-users

On 4/16/24 18:43, ToddAndMargo via perl6-users wrote:

On 4/16/24 01:21, ToddAndMargo via perl6-users wrote:

Hi All,

Windows 11

It has been so long that I have done one of these that
my brain is seizing.

https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea

C++

BOOL DeleteFileA(
   [in] LPCSTR lpFileName
);


Would some kind soul please show me how to do this again?

Many thanks,
-T


I got a good night's sleep and my head unfroze.

I figured it out.  I will post back how in a
few days or so.

-T




Hi All,

https://docs.raku.org/language/nativecall
is a wonderful documeht, but as far as I can
tell, they do not breakdown how to make an
API call.  They expect you to already know how
to do it.  So not for the beginners.

This is the code I came up with.  There is a lot
of the my libraries missing from this, if you want
them, I can eMail them to you.  I am only posting
this so you can get the idea of how to do this:

-T

# unit module NativeDelete;
# NativeDelete.rakumod

#`{

   Delete a filed directory with the Windows DeleteFileA function
   (fileapi.h) API with NativeCall.


https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea
   https://docs.raku.org/language/nativecall

   To use, place the following at the top of your program:

   use NativeDelete :ApiDeleteFile;
   use NativeCall;
   use NativeConstants;
   use NativeConvert :to-UTF8-c-str;
   use WinErr :WinGetLastError, :WinFormatMessage;

   Test one liner:
  Note: in Windows Explorer, right click on the file, left click on 
copy as path,
then paste the entire path.  Note the `\\?\` at the 
beginning for long file names.


  K:\Windows\NtUtil>echo abc > eraseme.txt && raku -I. -e "use 
NativeDelete :ApiDeleteFile; say ApiDeleteFile( Q[eraseme.txt] )" && 
type eraseme.txt

  OK
  The system cannot find the file specified.

  K:\Windows\NtUtil>echo abc > eraseme.txt && raku -I. -e "use 
NativeDelete :ApiDeleteFile; say ApiDeleteFile( Q[eraseme2.txt] )" && 
type eraseme.txt

  The system cannot find the file specified.
  abc

  raku -I. -e "use NativeDelete :ApiDeleteFile; say ApiDeleteFile( 
Q[\\?\D:\MyDocsBackup\backup2\Mozilla 2024-04-15 21;14;31 
(Full)\Firefox\Profiles\pj0elosu.default-release\storage\default\https+++505991220932649.webpush.freshchat.com^partitionKey=%28https%2Cbid13.com%29\cache\morgue\114\{7cccd5e9-a7aa-4349-a2e9-569baf007272}.final] 
);"

  OK

}

use NativeCall;
use NativeConstants;
use NativeConvert :to-UTF8-c-str;
use WinErr :WinGetLastError, :WinFormatMessage;


sub DeleteFileA(
   #`{
   C++
 BOOL DeleteFileA(
 [in] LPCSTR lpFileName
   );
   }

   CArray[uint8] $lpFileName
   )
   is native("Kernel32.dll")
   is symbol("DeleteFileA")
   returns BOOL
   { * };


sub ApiDeleteFile( Str $FileName ) returns Str is export( :ApiDeleteFile ) {
#`{
$FileName is the file name and optional path path
Format:  Q[D:\NtUtil\eraseme.txt]   Note the backslashes.

Returned "OK" if successful or the error message if not

Syntax
C++

BOOL DeleteFileA(
   [in] LPCSTR lpFileName
);
DLL Kernel32.dll

Return value
If the function succeeds, the return value is nonzero.
If the function fails, the return value is zero (0). To get 
extended error information, call GetLastError.


By default, the name is limited to MAX_PATH characters. To extend 
this limit to 32,767

wide characters, prepend "\\?\" to the path.

If using `\\?\` you must use the full path.

}

   my DWORD $LastError   = 0;
   my Str   $WinErrorMsg = "OK";
   my BOOL  $RtnValue= 1;
   my Str   $LongName= "";

   $LongName = $FileName;
   if $FileName.chars >= MAX_PATH  { $LongName = Q[\\?\] ~ $FileName; }

   my CArray[uint8] $lpFileName = to-UTF8-c-str( $LongName );
   $RtnValue = DeleteFileA( $lpFileName );

   sub GetLastError() is native("Kernel32") is symbol("GetLastError") 
returns DWORD { * };



   if $RtnValue == 0  {
  $LastError   = GetLastError();
  $WinErrorMsg = WinFormatMessage( $LastError );
   }
   return $WinErrorMsg;

}









Re: need native call help

2024-04-16 Thread ToddAndMargo via perl6-users

On 4/16/24 01:21, ToddAndMargo via perl6-users wrote:

Hi All,

Windows 11

It has been so long that I have done one of these that
my brain is seizing.

https://learn.microsoft.com/en-us/windows/win32/api/fileapi/nf-fileapi-deletefilea

C++

BOOL DeleteFileA(
   [in] LPCSTR lpFileName
);


Would some kind soul please show me how to do this again?

Many thanks,
-T


I got a good night's sleep and my head unfroze.

I figured it out.  I will post back how in a
few days or so.

-T



Re: I need sorting help

2024-03-16 Thread ToddAndMargo via perl6-users

On 3/2/24 05:13, Elizabeth Mattijsen wrote:

$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
.Numeric) // $_}).List)
afoo2
afoo12



On 2 Mar 2024, at 07:26, ToddAndMargo via perl6-users  
wrote:

Hi All,

@Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
})};

gives me

   Element [0]  
   Element [1]  
   Element [2]  
   Element [3]  
   Element [4]  
   Element [5]  
   Element [6]  
   Element [7]  
   Element [8]  
   Element [9]  

I need it to say

   Element [0]  
   Element [1]  
   Element [2]  
   Element [3]  
   Element [4]  
   Element [5]  
   Element [6]  
   Element [7]  
   Element [8]  
   Element [9]  

What did I goof up, this time?

Many thanks,
-T





Hi Liz,

Look what you have done to me!

$ raku -e '.say for bk-3.41.0.0>.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)'


bk-1.0.4.5
bk-1.1.0.9
bk-2.1.4.3
bk-3.4.1.5
bk-3.41.0.0

Awesome!
-T

--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~



Re: MAIN(*magic)

2024-03-15 Thread Bruce Gray


> On Mar 14, 2024, at 21:57, Mark Devine  wrote:
> 
> Rakoons,
>  
> I keep running into a space with Raku where it would be nice to have some 
> magic to reduce boilerplate.  I often make roles & classes with interface 
> options that flow from a consuming script’s MAIN arguments, then the first 
> bit of code at the top the MAIN block, then into instantiation.  If a person 
> makes nice utility libraries with lots of options for the user & employs them 
> a lot, the time consumed typing out the boilerplate adds up & bloats the 
> code.  Is there any way to shorten this pattern?  I was thinking about a 
> ‘switchable’ trait for attributes (with the naivety of a schoolboy).
>  
> my class Output {
> has $.csv  is switchable;
> has $.html is switchable;
>   .
>   .
>   .
> has $.xml is switchable;
> }
>  
> my class Timer {
> has $.countis switchable;
> has $.expire   is switchable;
> has $.interval is switchable;
> }
>  
> sub MAIN (
> Output.switchables, #= switchables from Class 'Output'
> Timer.switchables,  #= switchables from Class 'Timer'
> ) {
> my Timer $t.= new: :$expire, :$interval, :$count;   # variables 
> magically appear in scope
> my Output $o   .= new: :$csv, :$html, … , :$xml;# variables 
> magically appear in scope
> }
>  
> I estimate 10-50 lines of boilerplate could be removed from most of my Raku 
> scripts with something like that.  Unfortunately, I don’t possess any dark 
> magic for such things or I’d put forward an attempt.
>  
> Thanks,
>  
> Mark

Like lizmat, I also see no way to achieve your goal using the "is switchable" 
approach you have posited.
However, the thought of removing so much boilerplate pricks my thumbs, Ostara 
approaches, and it just turned midnight here, so Dark Magic will be attempted.

Thoughts:
* You don't need to have a $expire variable, or materialize any variable to 
allow feeding a CLI argument to a class' `.new()` constructor. You can skim off 
the arguments from @*ARGS, the same way many of the Getopt:: modules do. If you 
need them later, you can get them from the built object, e.g. `$t.count`.
* I expect is is harmless to expose *all* of the BUILDable attributes of the 
interfaced object types (which we can get via introspection!), so no need to 
mark individual attributes; you could mark the class itself with `is 
switchable`. 
* We could automate that `is switchable` (now for the whole class instead of 
its attributes) with a role, but why? More flexible to wrap (via module) *any* 
class/module with an OO API, even if not your own code! Proof-of-concept below.

Outline:
use Getopt::Attributes; # Not a real module (yet!)
my $sc = auto-cli( SomeClass );
sub MAIN ( ...just normal params, no need to list the params for all 
the objects built with `auto-cli`...  ) {
... code here can use `$sc`, which was created using args from 
the command-line ...
}


Test runs of code below:
$ raku poc_01.raku --count=5 --xml=foo.xml myfile.txt 
Timer  object  Timer.new(count => 5, expire => Any, interval => Any)
Output object  Output.new(csv => Any, html => Any, xml => "foo.xml", logger 
=> "localhost")
Remaining ARGS [myfile.txt]
Filename   myfile.txt

$ raku poc_01.raku --count=5 --xml=foo.xml --logger=abc myfile.txt 
Timer  object  Timer.new(count => 5, expire => Any, interval => Any)
Output object  Output.new(csv => Any, html => Any, xml => "foo.xml", logger 
=> "abc")
Remaining ARGS [myfile.txt]
Filename   myfile.txt

$ raku poc_01.raku myfile.txt 
Timer  object  Timer.new(count => Any, expire => Any, interval => Any)
Output object  Output.new(csv => Any, html => Any, xml => Any, logger => 
"localhost")
Remaining ARGS [myfile.txt]
Filename   myfile.txt



Actual proof-of-concept in a single file: poc_01.raku

# XXX In a fully-realized solution, this part would be in its own module.
# If it was Getopt::Attributes , it would live in 
lib/Getopt/Attributes.rakumod
# unit class Getopt::Attributes:ver<0.0.1>;

# Given a class, `auto-cli` introspects that class for its public accessors, 
knowing that those are valid named parameters for the class constructor. It 
then does a scan on @*ARGS, removing arguments that could be intended for that 
class. This must happen *before* MAIN runs, or MAIN will throw a USAGE error on 
the unexpected (from MAIN's perspective) arguments. The removed command-line 
arguments are merged with any provided defaults, and an instance of that class 
with the merged named arguments.
sub auto-cli ( Any:U $class, *%defaults ) is export {
my %opt = %defaults;

my @attrs = $class.^attributes
  .grep( *.has_accessor )
  .map(  *.name.subst(/^\S\S/) );
my $attr_re = /@attrs/;

for @*ARGS.keys.reverse -> $i {
if @*ARGS[$i] ~~ / ^ '--' ($attr_re) '=' (\S+) $ / {
my ($key, $va

Re: MAIN(*magic)

2024-03-15 Thread Elizabeth Mattijsen
> On 15 Mar 2024, at 03:57, Mark Devine  wrote:
> 
> Rakoons,
>  I keep running into a space with Raku where it would be nice to have some 
> magic to reduce boilerplate.  I often make roles & classes with interface 
> options that flow from a consuming script’s MAIN arguments, then the first 
> bit of code at the top the MAIN block, then into instantiation.  If a person 
> makes nice utility libraries with lots of options for the user & employs them 
> a lot, the time consumed typing out the boilerplate adds up & bloats the 
> code.  Is there any way to shorten this pattern?  I was thinking about a 
> ‘switchable’ trait for attributes (with the naivety of a schoolboy).
>  my class Output {
> has $.csv  is switchable;
> has $.html is switchable;
>   .
>   .
>   .
> has $.xml is switchable;
> }
>  my class Timer {
> has $.countis switchable;
> has $.expire   is switchable;
> has $.interval is switchable;
> }
>  sub MAIN (
> Output.switchables, #= switchables from Class 'Output'
> Timer.switchables,  #= switchables from Class 'Timer'
> ) {
> my Timer $t.= new: :$expire, :$interval, :$count;   # variables 
> magically appear in scope
> my Output $o   .= new: :$csv, :$html, … , :$xml;# variables 
> magically appear in scope
> }
>  I estimate 10-50 lines of boilerplate could be removed from most of my Raku 
> scripts with something like that.  Unfortunately, I don’t possess any dark 
> magic for such things or I’d put forward an attempt.

An interesting idea!

Unfortunately I don't see this happening in the legacy grammar.  And it may 
still be pretty hard to do in RakuAST.

If you'd want to have a solution now, I'd look at *generating* the boilerplate 
code where appropriate.  This approach is used in the core in several 
locations, most notably recently in the localization modules.


Liz



Re: I need sorting help

2024-03-09 Thread Ralph Mellor
On Sat, Mar 9, 2024 at 7:52 PM yary  wrote:

> how to sort by alpha & numeric segments (b3b, a1a, c20c) =>  (a1a, b3b, c2c)

Ahhh. D'oh. Thanks! 💚

Now I see what was required, or at least think I do:

.sort: {m:g/ \d+{make +$/} | \D+{make ~$/} /».made}

That does what was meant, right?

--
love, raiph


Re: I need sorting help

2024-03-09 Thread yary
Using my quick-intuition, are these methods sorting on the earliest number
withing the string, ignoring the non-digits?

$ raku -e '.say for .sort: {m/ \d+ /.Int}'
$ raku -e '.say for .sort: +*.match: / \d+ /'

let's see

$ raku -e '.say for .sort: {m/ \d+ /.Int}'
it1
does2
not3
matter10
what20
the30letters40
say31

What's been interesting about this thread is not only the variety of
solutions, also that the solutions are for two different questions-

how to sort by alpha & numeric segments (b3b, a1a, c20c) =>  (a1a, b3b, c2c)
how to sort by a numeric segment only (b3b, a1a, c20c) =>  (a1a, b3b, c20c)

-y


On Thu, Mar 7, 2024 at 4:40 PM Ralph Mellor  wrote:

> On Tue, Mar 5, 2024 at 7:01 AM ToddAndMargo via perl6-users
>  wrote:
>
> > >> $ raku -e '.say for .sort(*.split(/\d+/,
> :kv).map({ (try .Numeric) // $_}).List)'
> > >>
> > >> Yippee!
>
> > > raku -e '.say for .sort: { .comb(/ \d+ | \D+
> /).map({ .Int // .self }).cache };'
> >
> > Awesome!  Now I have two different methods!
>
> And now 4:
>
> $ raku -e '.say for .sort: {m/ \d+ /.Int}'
> bk1
> bk2
> bk10
> bk34
>
> or, same logic, but spelled differently:
>
> $ raku -e '.say for .sort: +*.match: / \d+ /'
> bk1
> bk2
> bk10
> bk34
>
> --
> love, raiph
>


Re: The SF Perl Raku Study Group, 04/10 at 1pm Pacific Time

2024-03-07 Thread Joseph Brenner
And this:

> March 10th, 2024  1pm in California, 9pm in the UK

Should've read "8pm in the UK".


On 3/7/24, Joseph Brenner  wrote:
> Note: Here in the US, we are about to "spring ahead" one mooorre time,
> and the 1pm I'm referring to is an hour earlier than many of you expect.
>
>"It's becoming increasingly unusual to read a report of a new
>technology or scientific discovery that doesn't breathlessly
>use the phrase 'it seems like science fiction'. The news
>cycle is currently dominated by hype about artificial
>intelligence (a gross mis-characterisation of machine
>learning algorithms and large language models). A couple of
>years ago it was breathless hype about cryptocurrency and
>blockchain technologies-- which turned out to be a financial
>services bubble ... "
>
>-- Charles Stross, November 10th, 2023,
>"We're sorry we created the Torment Nexus"
>
> The Raku Study Group
>
> March 10th, 2024  1pm in California, 9pm in the UK
>
> An informal meeting: drop by when you can, show us what you've got,
> ask and answer questions, or just listen and lurk.
>
> Perl and programming in general are fair game, along with Raku,
>
> Zoom meeting link:
>
> https://us02web.zoom.us/j/87052612966?pwd=cExtbzJLVkIyUGVZRGlYWlBBRTg1dz09
>
> Passcode: 4RakuRoll
>
> RSVPs are useful, though not needed:
>   https://www.meetup.com/san-francisco-perl/events/299663054/
>


Re: I need sorting help

2024-03-07 Thread Ralph Mellor
On Tue, Mar 5, 2024 at 7:01 AM ToddAndMargo via perl6-users
 wrote:

> >> $ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ 
> >> (try .Numeric) // $_}).List)'
> >>
> >> Yippee!

> > raku -e '.say for .sort: { .comb(/ \d+ | \D+ /).map({ 
> > .Int // .self }).cache };'
>
> Awesome!  Now I have two different methods!

And now 4:

$ raku -e '.say for .sort: {m/ \d+ /.Int}'
bk1
bk2
bk10
bk34

or, same logic, but spelled differently:

$ raku -e '.say for .sort: +*.match: / \d+ /'
bk1
bk2
bk10
bk34

--
love, raiph


Re: pint: Elizabeth, sort list???

2024-03-07 Thread Marc Chantreux
hello,

>  ==> sort({ | map { +$_ // $_ }, .split: /\d+/, :v }) ==> say()

ok … so I'm lost but I'm not even curious to understand why (because of
my lack of interest for the ==> operator :))

regards
marc

-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79



Re: pint: Elizabeth, sort list???

2024-03-07 Thread Fernando Santagata
Hi Marc,

This works:

 ==> sort({ | map { +$_ // $_ }, .split: /\d+/, :v }) ==>
say()

As the documentation says here https://docs.raku.org/routine/%3D%3D%26gt%3B

The precedence is very loose so you will need to use parentheses to assign
the result



On Thu, Mar 7, 2024 at 8:37 AM Marc Chantreux  wrote:

> hello,
>
> > How would you write that expression using the feed operator?
>
> I tried
>
> < afoo12 afoo2 >
> ==> {.sort: { | map { +$_ // $_ }, .split: /\d+/, :v }}
> ==> {map &say}
>
> and the error message is really interesting
>
> Only routine calls or variables that can '.append' may
> appear on either side of feed operators.
>
> on the other hand: I really don't understand why ==> even exists
> as method call syntax works well.
>
> < afoo12 afoo2 >
> .sort( { | map { +$_ // $_ }, .split: /\d+/, :v } )
> .map(&say)
>
> what I would love instead is something closer than the haskell's $
> operator with a very low priority so it could be possible to be
> parenthesis free.
>
> as example. I would like
>
> 1..10 ==> map * * 2 ==> say
>
> to be a joyful version of
>
> (1..10).map(* * 2).say
>
> regards
>
> --
> Marc Chantreux
> Pôle CESAR (Calcul et services avancés à la recherche)
> Université de Strasbourg
> 14 rue René Descartes,
> BP 80010, 67084 STRASBOURG CEDEX
> 03.68.85.60.79
>
>

-- 
Fernando Santagata


Re: pint: Elizabeth, sort list???

2024-03-07 Thread Marc Chantreux
hello,

> How would you write that expression using the feed operator?

I tried

< afoo12 afoo2 >
==> {.sort: { | map { +$_ // $_ }, .split: /\d+/, :v }}
==> {map &say}

and the error message is really interesting

Only routine calls or variables that can '.append' may
appear on either side of feed operators.

on the other hand: I really don't understand why ==> even exists
as method call syntax works well.

< afoo12 afoo2 >
.sort( { | map { +$_ // $_ }, .split: /\d+/, :v } )
.map(&say)

what I would love instead is something closer than the haskell's $
operator with a very low priority so it could be possible to be
parenthesis free.

as example. I would like

1..10 ==> map * * 2 ==> say

to be a joyful version of

(1..10).map(* * 2).say

regards

-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79



Re: pint: Elizabeth, sort list???

2024-03-06 Thread Jim Bollinger
Hi Elizabeth!

How would you write that expression using the feed operator?

Thanks,

Shimon

> On Mar 3, 2024, at 7:22 AM, Elizabeth Mattijsen  wrote:
> 
>> On 3 Mar 2024, at 03:32, ToddAndMargo via perl6-users  
>> wrote:
>> 
>>> On 3/2/24 05:13, Elizabeth Mattijsen wrote:
 .sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)
>> 
>>> Hi Elizabeth,
>>> It works perfectly.  Thank you!
>>> I have no idea why, I will ask you in another post
>> Would you take apart your sort piece by piece and explain
>> each part?
> 
> Actually, the expression can be refined a bit:
> 
> say .sort(*.split(/\d+/, :v).map({ (try .Int) // $_}).List)
> 
> Sort works by using `cmp` semantics by default.
> 
> If `cmp` is called on two lists, it will `cmp` each element and return the 
> result of the first comparison that did not produce `Same`.
> 
> If you call `sort` with a Callable that takes only one argument, it is taken 
> as the producer of the actual values that will be compared, basically doing a 
> Schwartzian transform under the hood.
> 
> A whatever code (which is what we specified here) produces a Callable with a 
> single argument.  So we'll be doing a Schwartzian transform under the hood.
> 
> The `split` splits the value (each element in the list) on any set of Numeric 
> characters (`\d+`), *but* also produces the strings that were split on 
> (`:v`). (The previous version had .kv, but that just produces more identical 
> entries in the list, which only will make comparisons slower).
> 
> The resulting values from the `split` are then mapped to an integer value (if 
> possible: `(try .Int)` and if that fails, just returns the value (`// $_`).  
> (The previous version had `.Numeric`, which will also work, but since `\d+` 
> can only produce integers, it's an extra unnecessary step).
> 
> Then convert the `.Seq` that is produced by the `.map` to a `List`.  
> Otherwise we'd be comparing `Seq` objects, and the semantics of those are 
> undefined.
> 
> So for `"afoo12" cmp "afoo2"`, we will be doing `("afoo", 12) cmp ("afoo", 
> 2)`.  Which would do: `"afoo" cmp "afoo"`, which produces `Same`, and then do 
> `12 cmp 2`, which will return `More`, and thus will cause swapping the order 
> of .
> 
> 
> Hope that made sense!



Re: pint: Elizabeth, sort list???

2024-03-05 Thread Marc Chantreux
Hi rakoons,

On Sun, Mar 03, 2024 at 01:22:45PM +0100, Elizabeth Mattijsen wrote:
> Actually, the expression can be refined a bit:
>
> say .sort(*.split(/\d+/, :v).map({ (try .Int) // $_}).List)

Which is gorgeous! thanks for that. I read the documentation which is
clear about all the magic in action there. So I played a little with it
and came with this sort

.say for <
afoo12 afoo2 abar12
abar9foo
abar64foo
abar64bang
abar64bang4foo
abar64bang4bar
abar64bang5bar
abar64foo
abar64foo4foo
abar64foo4bar
abar64foo14bar
abar64foo5bar
afoo13 afoo4
>.sort: { | map { +$_ // $_ }, .split: /\d+/, :v }

The ouput seems to be ok.

regards,
-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79



Re: I need sorting help

2024-03-04 Thread ToddAndMargo via perl6-users

On 3/4/24 23:01, ToddAndMargo via perl6-users wrote:
No I have 


Sould have been
   Now I have




Re: I need sorting help

2024-03-04 Thread ToddAndMargo via perl6-users

On 3/4/24 22:09, Bruce Gray wrote:




On Mar 4, 2024, at 15:55, ToddAndMargo via perl6-users  
wrote:



--snip--


$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
.Numeric) // $_}).List)'
bk1
bk2
bk10
bk34

Yippee!


tony@rn6:/home/linuxutil1$ raku -e '.say for .sort: { 
.comb(/ \d+ | \D+ /) .map({ .Int // .self })};'
bk1
bk10
bk2
bk34

Rats!  Thank for trying anyway!

--
love, todd



Wow! Very subtle trap with Seq!

The short answer is: Just add `.cache`:
raku -e '.say for .sort: { .comb(/ \d+ | \D+ /).map({ .Int 
// .self }).cache };'
bk1
bk2
bk10
bk34

When the elements that `.sort` is sorting are of type List or Array, the 
sorting happens one slot at a time; the sort happens on element [0] of each 
List, and ties are settled by [1] (or [2] if [1] are also a tie, etc). This 
enables `.sort` to behave very intuitively (after the shock wears off).

I did not detect the problem by eye, but when I broke it down on the 
commandline I see that Seq objects are being created by `.comb` and `.map`.
Objects of Seq type can only be read *once*, so the multiple reads that `.sort` 
needs would not play well with Seq. It does not matter whether you convert the 
numbers to a Numeric type (which you did correctly in the `.map`), they are 
still part of a Seq.

The .cache method turns the Seq into a List, and the sort behaves as you 
intended.
https://docs.raku.org/routine/cache


Awesome!  No I have two different methods!

-T



Re: I need sorting help

2024-03-04 Thread Bruce Gray



> On Mar 4, 2024, at 15:55, ToddAndMargo via perl6-users  
> wrote:


--snip--

> $ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
> .Numeric) // $_}).List)'
> bk1
> bk2
> bk10
> bk34
> 
> Yippee!
> 
> 
> tony@rn6:/home/linuxutil1$ raku -e '.say for .sort: { 
> .comb(/ \d+ | \D+ /) .map({ .Int // .self })};'
> bk1
> bk10
> bk2
> bk34
> 
> Rats!  Thank for trying anyway!
> 
> -- 
> love, todd


Wow! Very subtle trap with Seq!

The short answer is: Just add `.cache`:
raku -e '.say for .sort: { .comb(/ \d+ | \D+ /).map({ .Int 
// .self }).cache };' 
bk1
bk2
bk10
bk34

When the elements that `.sort` is sorting are of type List or Array, the 
sorting happens one slot at a time; the sort happens on element [0] of each 
List, and ties are settled by [1] (or [2] if [1] are also a tie, etc). This 
enables `.sort` to behave very intuitively (after the shock wears off).

I did not detect the problem by eye, but when I broke it down on the 
commandline I see that Seq objects are being created by `.comb` and `.map`.
Objects of Seq type can only be read *once*, so the multiple reads that `.sort` 
needs would not play well with Seq. It does not matter whether you convert the 
numbers to a Numeric type (which you did correctly in the `.map`), they are 
still part of a Seq.

The .cache method turns the Seq into a List, and the sort behaves as you 
intended.
https://docs.raku.org/routine/cache


-- 
Hope this helps,
Bruce Gray (Util of PerlMonks)



Re: I need sorting help

2024-03-04 Thread ToddAndMargo via perl6-users

On 3/4/24 13:55, ToddAndMargo via perl6-users wrote:

On 3/4/24 12:40, Ralph Mellor wrote:

On Sat, Mar 2, 2024 at 6:26 AM ToddAndMargo via perl6-users
 wrote:


@Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int 
// .self })};


In case another answer is helpful...

First, a simplified sort that produces the same
result as your code above:

@Sorted_List .= sort: *.match: / \d+ /;

I can explain that in a later comment if you want, but it's
all stuff I recall you figuring out in the past, so for now I'll
just move on to address the change you wanted.

The problem you had was that sort defaults to a string sort.
In string sorting 1, 10, 2 are already sorted, but you instead
want numeric order, which sorts those three into 1, 2, 10.

To do that, coerce the sort value to numeric by inserting a `+`:

@Sorted_List .= sort: +*.match: / \d+ /;

--
love, raiph



$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ 
(try .Numeric) // $_}).List)'

bk1
bk2
bk10
bk34

Yippee!


tony@rn6:/home/linuxutil1$ raku -e '.say for .sort: { 
.comb(/ \d+ | \D+ /) .map({ .Int // .self })};'

bk1
bk10
bk2
bk34

Rats!  Thank for trying anyway!




$ raku -e '.say for .sort: { .comb(/ \d+ | \D+ /) 
.map({ .Str // .self })};'

bk1
bk10
bk2
bk34


Double Rats!


Re: I need sorting help

2024-03-04 Thread ToddAndMargo via perl6-users

On 3/4/24 12:40, Ralph Mellor wrote:

On Sat, Mar 2, 2024 at 6:26 AM ToddAndMargo via perl6-users
 wrote:


@Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
})};


In case another answer is helpful...

First, a simplified sort that produces the same
result as your code above:

@Sorted_List .= sort: *.match: / \d+ /;

I can explain that in a later comment if you want, but it's
all stuff I recall you figuring out in the past, so for now I'll
just move on to address the change you wanted.

The problem you had was that sort defaults to a string sort.
In string sorting 1, 10, 2 are already sorted, but you instead
want numeric order, which sorts those three into 1, 2, 10.

To do that, coerce the sort value to numeric by inserting a `+`:

@Sorted_List .= sort: +*.match: / \d+ /;

--
love, raiph



$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ 
(try .Numeric) // $_}).List)'

bk1
bk2
bk10
bk34

Yippee!


tony@rn6:/home/linuxutil1$ raku -e '.say for .sort: { 
.comb(/ \d+ | \D+ /) .map({ .Int // .self })};'

bk1
bk10
bk2
bk34

Rats!  Thank for trying anyway!

--
love, todd


Re: I need sorting help

2024-03-04 Thread Ralph Mellor
> @Sorted_List .= sort: *.match: / \d+ /;
> ...
> @Sorted_List .= sort: +*.match: / \d+ /;

Or perhaps easier to understand:

@Sorted_List .= sort: {m/ \d+ /.Str}
vs
@Sorted_List .= sort: {m/ \d+ /.Int}

love, raiph


Re: I need sorting help

2024-03-04 Thread Ralph Mellor
On Sat, Mar 2, 2024 at 6:26 AM ToddAndMargo via perl6-users
 wrote:
>
> @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
> })};

In case another answer is helpful...

First, a simplified sort that produces the same
result as your code above:

@Sorted_List .= sort: *.match: / \d+ /;

I can explain that in a later comment if you want, but it's
all stuff I recall you figuring out in the past, so for now I'll
just move on to address the change you wanted.

The problem you had was that sort defaults to a string sort.
In string sorting 1, 10, 2 are already sorted, but you instead
want numeric order, which sorts those three into 1, 2, 10.

To do that, coerce the sort value to numeric by inserting a `+`:

@Sorted_List .= sort: +*.match: / \d+ /;

--
love, raiph


Re: missing block

2024-03-03 Thread ToddAndMargo via perl6-users

On 3/3/24 04:25, Elizabeth Mattijsen wrote:

On 3 Mar 2024, at 05:12, ToddAndMargo via perl6-users  
wrote:
$ raku -I./ -c CobianWrapper.pl6
Missing block
at /home/CDs/Windows/NtUtil/CobianWrapper.pl6:1000

1000 is the last line in my code.  I presume by
"block" they mean something like "]" or "}"

Do I really have to read 1000 lines of code to find my screw
up?   Anyone have a tip on how to find it quicker?


I use `vim` as the editor.

In `vim` if I have this situation, then I put the cursor on the first opening { 
 and press `%`.  This brings me to the corresponding closing }.

If the associated closing curly does not match your expectations, then you're 
nearing the source of the problem.

I assume other code editor have a similar `%` functionality.


Hi Elizabeth,

I learned vi about 35 years ago.  I still use
it occasionally.  I will have to try out that
% feature out.  Thank you!   (I just made
a quick "Keeper" out of it.)

I use Geany for programming a lot.  Primarily
as is works well with ssh X11 over poor internet
connections.

Geany has a thing were you park on a bracket of
some type and it will turn the other end blue.
So, something similar to vi (an alias to vim).

To work around the missing block issue, I always
place both sides of a {} before writing inside
them.  It does not always work if I ramble too much.

And it is the tip off that I have rambled on too
much and need to put some things into subs.
Considering I am a YUGE proponent of "top down"
programming, I really should know better.

This is what became of your help:

sub SortList( @List, Str $Msg, Bool $NoDebug )  {
   my @Sorted = Empty;
   @Sorted = @List.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // 
$_}).List);


   if  %Options< Debug >  && not $NoDebug  {
  print "$Msg";
  for @Sorted.kv -> $Index, $Element  {
  print "   Element [$Index]  <$Element>\n";
  }
   }
   return @Sorted;
}


sub ListParentDir( Str $Msg, Bool $NoDebug = False  )  {
   # list and sort %Options
   my @List = Empty;
   for dir( %Options ) { push @List, $_.Str };
   @List = SortList @List, $Msg, $NoDebug;
   return @List;
}


It really cut down on the clutter and made missing
bracket much easier to find.

Oh and you helped me fix a bug in my program that I
had though was a Windows error that had been going
on for years.  Thank you again!

-T





Re: pint: Elizabeth, sort list???

2024-03-03 Thread Elizabeth Mattijsen
> On 3 Mar 2024, at 03:32, ToddAndMargo via perl6-users  
> wrote:
> 
>> On 3/2/24 05:13, Elizabeth Mattijsen wrote:
>>> .sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)
> 
>> Hi Elizabeth,
>> It works perfectly.  Thank you!
>> I have no idea why, I will ask you in another post
> Would you take apart your sort piece by piece and explain
> each part?

Actually, the expression can be refined a bit:

say .sort(*.split(/\d+/, :v).map({ (try .Int) // $_}).List)

Sort works by using `cmp` semantics by default.

If `cmp` is called on two lists, it will `cmp` each element and return the 
result of the first comparison that did not produce `Same`.

If you call `sort` with a Callable that takes only one argument, it is taken as 
the producer of the actual values that will be compared, basically doing a 
Schwartzian transform under the hood.

A whatever code (which is what we specified here) produces a Callable with a 
single argument.  So we'll be doing a Schwartzian transform under the hood.

The `split` splits the value (each element in the list) on any set of Numeric 
characters (`\d+`), *but* also produces the strings that were split on (`:v`). 
(The previous version had .kv, but that just produces more identical entries in 
the list, which only will make comparisons slower).

The resulting values from the `split` are then mapped to an integer value (if 
possible: `(try .Int)` and if that fails, just returns the value (`// $_`).  
(The previous version had `.Numeric`, which will also work, but since `\d+` can 
only produce integers, it's an extra unnecessary step).

Then convert the `.Seq` that is produced by the `.map` to a `List`.  Otherwise 
we'd be comparing `Seq` objects, and the semantics of those are undefined.

So for `"afoo12" cmp "afoo2"`, we will be doing `("afoo", 12) cmp ("afoo", 2)`. 
 Which would do: `"afoo" cmp "afoo"`, which produces `Same`, and then do `12 
cmp 2`, which will return `More`, and thus will cause swapping the order of 
.


Hope that made sense!

Re: missing block

2024-03-02 Thread ToddAndMargo via perl6-users

On 3/2/24 20:12, ToddAndMargo via perl6-users wrote:

Hi All,

$ raku -I./ -c CobianWrapper.pl6
Missing block
at /home/CDs/Windows/NtUtil/CobianWrapper.pl6:1000

1000 is the last line in my code.  I presume by
"block" they mean something like "]" or "}"

Do I really have to read 1000 lines of code to find my screw
up?   Anyone have a tip on how to find it quicker?

Many thanks,
-T


Found it.  It was a missing "}"

I did it by erasing the innards of the suspected directory
(after making a copy of it of cource), then running -c.
Syntax came back okay.

Then it was a meter of doing he same to blocks inside
the directory until I finally narrowed it down.

Geez!!!

-T



Re: pint: Elizabeth, sort list???

2024-03-02 Thread ToddAndMargo via perl6-users

On 3/2/24 19:14, Clifton Wood wrote:

.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)


Can you take apart the above for me?


Re: ping: Elizabeth, sort list???

2024-03-02 Thread ToddAndMargo via perl6-users

Sorry, that was suppose to be "ping: not "pint:


Re: pint: Elizabeth, sort list???

2024-03-02 Thread Clifton Wood
https://gist.github.com/Xliff/286f1359e40d192d724ed9b900354015

On Sat, Mar 2, 2024 at 9:32 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> > On 3/2/24 05:13, Elizabeth Mattijsen wrote:
> >> .sort(*.split(/\d+/, :kv).map({ (try .Numeric) //
> $_}).List)
>
> > Hi Elizabeth,
> >
> >  It works perfectly.  Thank you!
> >
> >  I have no idea why, I will ask you in another post
>
> Hi Elizabeth,
>
> Would you take apart your sort piece by piece and explain
> each part?
>
> Many thanks,
> -T
>
>
>


Re: I need sorting help

2024-03-02 Thread Clifton Wood
Easy multisort!

my @h = (

{

name => "albert",
age => 40,
size => 2

},
{

},
{

);

#
({age => 40, name => albert, size => 2} {age => 69, name => albert, size =>
3} {age => 22, name => andy, size => 3})


On Sat, Mar 2, 2024 at 9:29 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 3/2/24 05:13, Elizabeth Mattijsen wrote:
> > .sort(*.split(/\d+/, :kv).map({ (try .Numeric) //
> $_}).List)
>
> Hi Elizabeth,
>
>   It works perfectly.  Thank you!
>
>   I have no idea why, I will ask you in another post
>
> -T
>


Re: I need sorting help

2024-03-02 Thread ToddAndMargo via perl6-users

On 3/2/24 05:13, Elizabeth Mattijsen wrote:

.sort(*.split(/\d+/, :kv).map({ (try .Numeric) // $_}).List)


Hi Elizabeth,

 It works perfectly.  Thank you!

 I have no idea why, I will ask you in another post

-T


RE: I need sorting help

2024-03-02 Thread Mark Devine
Elizabeth,

I have been looking for that one to sort operating system devices.  Exceptional 
timing!

Thanks,

Mark Devine
(202) 878-1500

-Original Message-
From: Elizabeth Mattijsen  
Sent: Saturday, March 2, 2024 8:14 AM
To: ToddAndMargo via perl6-users 
Subject: Re: I need sorting help

$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
.Numeric) // $_}).List)
afoo2
afoo12


> On 2 Mar 2024, at 07:26, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
> })};
> 
> gives me
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> I need it to say
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> What did I goof up, this time?
> 
> Many thanks,
> -T



Re: I need sorting help

2024-03-02 Thread Elizabeth Mattijsen
$ raku -e '.say for .sort(*.split(/\d+/, :kv).map({ (try 
.Numeric) // $_}).List)
afoo2
afoo12


> On 2 Mar 2024, at 07:26, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> @Sorted_List = @Sorted_List.sort: { .comb(/ \d+ | \D+ /) .map({ .Int // .self 
> })};
> 
> gives me
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> I need it to say
> 
>   Element [0]  
>   Element [1]  
>   Element [2]  
>   Element [3]  
>   Element [4]  
>   Element [5]  
>   Element [6]  
>   Element [7]  
>   Element [8]  
>   Element [9]  
> 
> What did I goof up, this time?
> 
> Many thanks,
> -T



Re: disable coercing?

2024-02-26 Thread ToddAndMargo via perl6-users

On 2/25/24 17:45, Joseph Brenner wrote:

Would this trick help?  You can define a "subset" that restricts
values to the uint16 range:

  my subset FussyUint16 of Int where 0 ..^ 2¹⁶;
  my FussyUint16 $x;
  $x = -1;
  ## Type check failed in assignment to $x; expected FussyUint16
but got Int (-1)


I got around it by cleaning up my act.  It was
really my fault for not respecting what Raku
was trying to do.  Since I endeavor to define
all my variables, I should have known better.


Re: disable coercing?

2024-02-25 Thread Joseph Brenner
Would this trick help?  You can define a "subset" that restricts
values to the uint16 range:

 my subset FussyUint16 of Int where 0 ..^ 2¹⁶;
 my FussyUint16 $x;
 $x = -1;
 ## Type check failed in assignment to $x; expected FussyUint16
but got Int (-1)


Re: pm6 naming convention

2024-02-12 Thread ToddAndMargo via perl6-users

On 2/12/24 15:04, Will Coleda wrote:



On Mon, Feb 12, 2024 at 5:32 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:


On 2/12/24 14:29, ToddAndMargo via perl6-users wrote:
 >>> On Mon, Feb 12, 2024 at 3:24 PM ToddAndMargo via perl6-users
 >>> mailto:perl6-users@perl.org>
>> wrote:
 >>
 >>>     Has .pl6 been renamed too?
 >
 > On 2/12/24 12:37, Will Coleda wrote:
 >  > Please see: https://docs.raku.org/language/filename-extensions

 >  > >
 >  >
 >
 > Thank you!  I saved it in my own documentation.

Interesting that the site calls Raku code a
"script".  I wonder just exactly how many
thousands of lines of code I have to write before
I can officially call it a "program"?


Pull requests welcome, and if you have any specific notes about searches 
that aren't working for you, please report them on 
https://github.com/Raku/doc/issues .


You can click on the edit icon on that doc page to easily submit a PR.



Hi Will,

Richard wrote me off line that the search had been updated
too, so I gave it the search I bombed out a month or so ago:

https://www.google.com/search?q=site%3Adocs.raku.org+unit32

Forth one down.

int8(int8_t in C)
int16   (int16_t in C)
int32   (int32_t in C)
int64   (int64_t in C)
byte, uint8 (uint8_t in C)
uint16  (uint16_t in C)
uint32  (uint32_t in C)
uint64  (uint64_t in C)
num32   (float in C)
num64   (double in C)

Yippee!

Now to figure out why I was bombing on int32 (DWORD)
[2] > my uint32 $x = 2
2
[3] > my int32 $y = $x.int32

No such method 'int32' for invocant of type 'Int'.  Did you mean 'Int'?
  in block  at  line 1
  in any  at 
/opt/rakudo-pkg/bin/../share/perl6/runtime/perl6.moarvm line 1
  in any  at 
/opt/rakudo-pkg/bin/../share/perl6/runtime/perl6.moarvm line 1



But this works:

[4] > my int32 $y = $x.Int
2

H.

-T


Re: pm6 naming convention

2024-02-12 Thread ToddAndMargo via perl6-users

On 2/12/24 15:04, Will Coleda wrote:
Pull requests welcome, and if you have any specific notes about searches 
that aren't working for you, please report them on 
https://github.com/Raku/doc/issues .


You can click on the edit icon on that doc page to easily submit a PR.


I will check it out!  Thank you!


Re: pm6 naming convention

2024-02-12 Thread Will Coleda
On Mon, Feb 12, 2024 at 5:32 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

> On 2/12/24 14:29, ToddAndMargo via perl6-users wrote:
> >>> On Mon, Feb 12, 2024 at 3:24 PM ToddAndMargo via perl6-users
> >>> mailto:perl6-users@perl.org>> wrote:
> >>
> >>> Has .pl6 been renamed too?
> >
> > On 2/12/24 12:37, Will Coleda wrote:
> >  > Please see: https://docs.raku.org/language/filename-extensions
> >  > 
> >  >
> >
> > Thank you!  I saved it in my own documentation.
>
> Interesting that the site calls Raku code a
> "script".  I wonder just exactly how many
> thousands of lines of code I have to write before
> I can officially call it a "program"?
>
>
Pull requests welcome, and if you have any specific notes about searches
that aren't working for you, please report them on
https://github.com/Raku/doc/issues.

You can click on the edit icon on that doc page to easily submit a PR.


Re: pm6 naming convention

2024-02-12 Thread ToddAndMargo via perl6-users

On 2/12/24 14:29, ToddAndMargo via perl6-users wrote:
On Mon, Feb 12, 2024 at 3:24 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:



    Has .pl6 been renamed too?


On 2/12/24 12:37, Will Coleda wrote:
 > Please see: https://docs.raku.org/language/filename-extensions
 > 
 >

Thank you!  I saved it in my own documentation.


Interesting that the site calls Raku code a
"script".  I wonder just exactly how many
thousands of lines of code I have to write before
I can officially call it a "program"?



Re: pm6 naming convention

2024-02-12 Thread ToddAndMargo via perl6-users
On Mon, Feb 12, 2024 at 3:24 PM ToddAndMargo via perl6-users 
mailto:perl6-users@perl.org>> wrote:



Has .pl6 been renamed too?


On 2/12/24 12:37, Will Coleda wrote:
> Please see: https://docs.raku.org/language/filename-extensions
> 
>

Thank you!  I saved it in my own documentation.

I can't find a thing anymore since they updated the
documentation site.  I use google a lot and my own
documentation.  Looking up "raku" gets me a ton of hits
on Japanese pottery, so it is frustrating.


Re: pm6 naming convention

2024-02-12 Thread Will Coleda
Please see: https://docs.raku.org/language/filename-extensions

On Mon, Feb 12, 2024 at 3:24 PM ToddAndMargo via perl6-users <
perl6-users@perl.org> wrote:

>
> >> On 12 Feb 2024, at 20:34, ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
> >>
> >>
>  On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users <
> perl6-users@perl.org> wrote:
> 
>  Hi All,
> 
>  I use AnyDesk for remoter customer support.  Work rather well.
> 
>  The file transfer portion, which I adore, posts a Microsoft
>  Office Publisher Icon (a big one) when it hits a .pm6 modules.
> 
>  Is there a different naming convention I can use for my
>  modules that does not mimic some other program?
> 
>  Many thanks,
>  -T
> >>
> >> On 2/12/24 11:11, Elizabeth Mattijsen wrote:
> >>> .rakumod
> >>
> >>
> >> Thank you!
> >>
> >> Is there a way to get raku to ignore pm (perl 5)
> >> module naming?
>
> On 2/12/24 11:40, Elizabeth Mattijsen wrote:
>  > It's been marked as DEPRECATED since 2023.12 I believe.
>  >
>
> Cool.
>
> Has .pl6 been renamed too?
>
>


Re: pm6 naming convention

2024-02-12 Thread ToddAndMargo via perl6-users




On 12 Feb 2024, at 20:34, ToddAndMargo via perl6-users  
wrote:



On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users  
wrote:

Hi All,

I use AnyDesk for remoter customer support.  Work rather well.

The file transfer portion, which I adore, posts a Microsoft
Office Publisher Icon (a big one) when it hits a .pm6 modules.

Is there a different naming convention I can use for my
modules that does not mimic some other program?

Many thanks,
-T


On 2/12/24 11:11, Elizabeth Mattijsen wrote:

.rakumod



Thank you!

Is there a way to get raku to ignore pm (perl 5)
module naming?


On 2/12/24 11:40, Elizabeth Mattijsen wrote:
> It's been marked as DEPRECATED since 2023.12 I believe.
>

Cool.

Has .pl6 been renamed too?



Re: pm6 naming convention

2024-02-12 Thread Elizabeth Mattijsen
It's been marked as DEPRECATED since 2023.12 I believe.

> On 12 Feb 2024, at 20:34, ToddAndMargo via perl6-users  
> wrote:
> 
> 
>>> On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> I use AnyDesk for remoter customer support.  Work rather well.
>>> 
>>> The file transfer portion, which I adore, posts a Microsoft
>>> Office Publisher Icon (a big one) when it hits a .pm6 modules.
>>> 
>>> Is there a different naming convention I can use for my
>>> modules that does not mimic some other program?
>>> 
>>> Many thanks,
>>> -T
> 
> On 2/12/24 11:11, Elizabeth Mattijsen wrote:
> > .rakumod
> 
> 
> Thank you!
> 
> Is there a way to get raku to ignore pm (perl 5)
> module naming?
> 



Re: pm6 naming convention

2024-02-12 Thread ToddAndMargo via perl6-users




On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users  
wrote:

Hi All,

I use AnyDesk for remoter customer support.  Work rather well.

The file transfer portion, which I adore, posts a Microsoft
Office Publisher Icon (a big one) when it hits a .pm6 modules.

Is there a different naming convention I can use for my
modules that does not mimic some other program?

Many thanks,
-T


On 2/12/24 11:11, Elizabeth Mattijsen wrote:
> .rakumod


Thank you!

Is there a way to get raku to ignore pm (perl 5)
module naming?



Re: pm6 naming convention

2024-02-12 Thread Elizabeth Mattijsen
.rakumod

> On 6 Feb 2024, at 18:08, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> I use AnyDesk for remoter customer support.  Work rather well.
> 
> The file transfer portion, which I adore, posts a Microsoft
> Office Publisher Icon (a big one) when it hits a .pm6 modules.
> 
> Is there a different naming convention I can use for my
> modules that does not mimic some other program?
> 
> Many thanks,
> -T
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: who call raku?

2024-02-10 Thread ToddAndMargo via perl6-users

On 2/10/24 16:01, ToddAndMargo via perl6-users wrote:

On 2/10/24 15:26, Marc Chantreux wrote:
On Thu, Feb 08, 2024 at 02:25:00PM -0800, ToddAndMargo via perl6-users 
wrote:

Actually, I am looking for the name of the calling program:
Cobian, Task manager, deamon, etc..


linux centric anwser:

raku -e 'say "/proc/{"/proc/$*PID/stat".IO.words[3]}/comm".IO.lines[0]'

hth




$ raku -e 'say "/proc/{"/proc/$*PID/stat".IO.words[3]}/comm".IO.lines[0]'
bash


Very cool.  Thank you.

I also need (only a little bit, I figured a way
around it) to kow how to do it in Windows.




Winsdows no so cool.  perl -e does not get past the
quoting issue from the command console.

So:

>raku

[0] > say "/proc/{"/proc/$*PID/stat".IO.words[3]}/comm".IO.lines[0]
Failed to open file K:\proc\6640\stat: No such file or directory
  in method throw at 'SETTING::'src/core.c/Exception.rakumod line 65
  in method fail at 'SETTING::'src/core.c/Exception.rakumod line 89
  in block  at 'SETTING::'src/core.c/IO/Handle.rakumod line 158
  in method open at 'SETTING::'src/core.c/IO/Handle.rakumod line 155
  in method open at 'SETTING::'src/core.c/IO/Path.rakumod line 212
  in method words at 'SETTING::'src/core.c/IO/Path.rakumod line 805
  in block  at  line 1



Re: who call raku?

2024-02-10 Thread ToddAndMargo via perl6-users

On 2/10/24 15:26, Marc Chantreux wrote:

On Thu, Feb 08, 2024 at 02:25:00PM -0800, ToddAndMargo via perl6-users wrote:

Actually, I am looking for the name of the calling program:
Cobian, Task manager, deamon, etc..


linux centric anwser:

raku -e 'say "/proc/{"/proc/$*PID/stat".IO.words[3]}/comm".IO.lines[0]'

hth




$ raku -e 'say "/proc/{"/proc/$*PID/stat".IO.words[3]}/comm".IO.lines[0]'
bash


Very cool.  Thank you.

I also need (only a little bit, I figured a way
around it) to kow how to do it in Windows.


Re: who call raku?

2024-02-10 Thread Marc Chantreux
On Thu, Feb 08, 2024 at 02:25:00PM -0800, ToddAndMargo via perl6-users wrote:
> Actually, I am looking for the name of the calling program:
> Cobian, Task manager, deamon, etc..

linux centric anwser:

raku -e 'say "/proc/{"/proc/$*PID/stat".IO.words[3]}/comm".IO.lines[0]'

hth

-- 
Marc Chantreux
Pôle CESAR (Calcul et services avancés à la recherche)
Université de Strasbourg
14 rue René Descartes,
BP 80010, 67084 STRASBOURG CEDEX
03.68.85.60.79



Re: disable coercing?

2024-02-10 Thread ToddAndMargo via perl6-users

On 2/10/24 02:41, Elizabeth Mattijsen wrote:

On 10 Feb 2024, at 08:56, ToddAndMargo via perl6-users  
wrote:

Hi All,

Is there a switch to tell Raku to bomb out with a
type mismatch rather than coercing the following?


my uint16 $x = -1

65535


No, this is intentional behaviour on native integers.


Rats.

I type cast my variable when I can to keep me out of trouble
("Expected Int but got Str").  Guess I got a bit too
lazy.   I am going to have to be more careful when
dealing with Cardinals (unit's).  I did get stung by this
yesterday. Took me hours to figure it out.


Note that you can increment such a value without problems:

[0] > my uint16 $x = -1;
65535
[1] > ++$x
0


Oh now that is really sneaky and speaks
of any underlying understand of bit wise
operations!  :-)

Thank you!




Re: disable coercing?

2024-02-10 Thread Elizabeth Mattijsen
> On 10 Feb 2024, at 08:56, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Is there a switch to tell Raku to bomb out with a
> type mismatch rather than coercing the following?
> 
> > my uint16 $x = -1
> 65535

No, this is intentional behaviour on native integers.

Note that you can increment such a value without problems:

[0] > my uint16 $x = -1;
65535
[1] > ++$x
0

Re: who call raku?

2024-02-08 Thread ToddAndMargo via perl6-users

On 2/8/24 14:25, ToddAndMargo via perl6-users wrote:

On 2/8/24 13:19, Bruce Gray wrote:



On Feb 8, 2024, at 15:12, ToddAndMargo via perl6-users 
 wrote:


Hi All,

Is there one of those fancy system variables that will
tell me who called/started raku?


Ooops.  I should have said "what called" not "who called".


raku -e 'say $*USER'
bruce




Actually, I am looking for the name of the calling program:
Cobian, Task manager, deamon, etc..


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~



Re: Session ID

2024-02-08 Thread ToddAndMargo via perl6-users

On 2/6/24 17:50, ToddAndMargo via perl6-users wrote:

Hi All

Windows 10 and 11

Does Raku have a system call that will tell
me my "session ID"?

Many thanks,
-T



So far what I have come up with is a system call to "wmic":

>raku -e "sleep 14"

>wmic process where "name='raku.exe'" get ProcessID,SessionID,CommandLine
CommandLine  ProcessId  SessionId
raku  -e "sleep 14"  5020   1


Re: who call raku?

2024-02-08 Thread ToddAndMargo via perl6-users

On 2/8/24 13:19, Bruce Gray wrote:




On Feb 8, 2024, at 15:12, ToddAndMargo via perl6-users  
wrote:

Hi All,

Is there one of those fancy system variables that will
tell me who called/started raku?


raku -e 'say $*USER'
bruce




Actually, I am looking for the name of the calling program:
Cobian, Task manager, deamon, etc..


Re: who call raku?

2024-02-08 Thread Bruce Gray



> On Feb 8, 2024, at 15:12, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Is there one of those fancy system variables that will
> tell me who called/started raku?

raku -e 'say $*USER'
bruce

-- 
Hope this helps,
Bruce Gray (Util of Perlmonks)



Re: -c question

2024-02-06 Thread ToddAndMargo via perl6-users

On 2/6/24 09:03, Bruce Gray wrote:




On Feb 6, 2024, at 10:52, ToddAndMargo via perl6-users  
wrote:


On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users  
wrote:

Hi All,

Is there a way to syntax a module?  Sort of like the "-c"
option on main programs?

Many thanks,
-T


On 2/6/24 01:34, Elizabeth Mattijsen wrote:

$ raku -c foo.rakumod
Syntax OK



$ raku -c WinMessageBox.pm6
===SORRY!=== Error while compiling /home/CDs/Windows/NtUtil/WinMessageBox.pm6
Could not find NativeConvert in:
/home/tony/.raku
/opt/rakudo-pkg/share/perl6/site
/opt/rakudo-pkg/share/perl6/vendor
/opt/rakudo-pkg/share/perl6/core
CompUnit::Repository::AbsolutePath<4639587332824>
CompUnit::Repository::NQP<4639586267208>
CompUnit::Repository::Perl5<4639586267248>
at /home/CDs/Windows/NtUtil/WinMessageBox.pm6:50

$ which NativeConvert.pm6
./NativeConvert.pm6
and three other pm.6's WinMessageBox imports.

I can only compile check my modules if I
import them to a program and -c the program.

For example, the following program uses
the above module:
$ raku -c CobianWrapper.pl6
Syntax OK

I just want to do a syntax check on my modules
at time without the program.

:'(


The wrapper program can be a `-e` one-liner, like:
 raku -c -e 'use NativeCall;'
 Syntax OK
 
Does this work for you?

 raku -c -e 'use WinMessageBox;'
 


Rats!

$ raku -c -e 'use WinMessageBox;'
===SORRY!=== Error while compiling -e
Could not find WinMessageBox in:
/home/tony/.raku
/opt/rakudo-pkg/share/perl6/site
/opt/rakudo-pkg/share/perl6/vendor
/opt/rakudo-pkg/share/perl6/core
CompUnit::Repository::AbsolutePath<2965876076768>
CompUnit::Repository::NQP<2965910068576>
CompUnit::Repository::Perl5<2965910068616>
at -e:1

$ raku -I./ -c WinMessageBox.pm6
Syntax OK


--
~~
Computers are like air conditioners.
They malfunction when you open windows
~~



Re: -c question

2024-02-06 Thread ToddAndMargo via perl6-users




On 6 Feb 2024, at 17:52, ToddAndMargo via perl6-users  
wrote:


On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users  
wrote:

Hi All,

Is there a way to syntax a module?  Sort of like the "-c"
option on main programs?

Many thanks,
-T


On 2/6/24 01:34, Elizabeth Mattijsen wrote:

$ raku -c foo.rakumod
Syntax OK



$ raku -c WinMessageBox.pm6
===SORRY!=== Error while compiling /home/CDs/Windows/NtUtil/WinMessageBox.pm6
Could not find NativeConvert in:
/home/tony/.raku
/opt/rakudo-pkg/share/perl6/site
/opt/rakudo-pkg/share/perl6/vendor
/opt/rakudo-pkg/share/perl6/core
CompUnit::Repository::AbsolutePath<4639587332824>
CompUnit::Repository::NQP<4639586267208>
CompUnit::Repository::Perl5<4639586267248>
at /home/CDs/Windows/NtUtil/WinMessageBox.pm6:50

$ which NativeConvert.pm6
./NativeConvert.pm6
and three other pm.6's WinMessageBox imports.

I can only compile check my modules if I
import them to a program and -c the program.

For example, the following program uses
the above module:
$ raku -c CobianWrapper.pl6
Syntax OK

I just want to do a syntax check on my modules
at time without the program.

:'(


On 2/6/24 08:57, Elizabeth Mattijsen wrote:
> Do you have some "use lib 'foo'" setting in your program?
>
> If so, use that on the command-line, e.g.:
>
>  $ raku -Ifoo -c bar.rakumod
>

Indeed I do.  Will the above command check those
modules too, or just verify that they are there?





Re: -c question

2024-02-06 Thread Bruce Gray



> On Feb 6, 2024, at 10:52, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> Is there a way to syntax a module?  Sort of like the "-c"
>>> option on main programs?
>>> 
>>> Many thanks,
>>> -T
> 
> On 2/6/24 01:34, Elizabeth Mattijsen wrote:
> > $ raku -c foo.rakumod
> > Syntax OK
> >
> 
> $ raku -c WinMessageBox.pm6
> ===SORRY!=== Error while compiling /home/CDs/Windows/NtUtil/WinMessageBox.pm6
> Could not find NativeConvert in:
>/home/tony/.raku
>/opt/rakudo-pkg/share/perl6/site
>/opt/rakudo-pkg/share/perl6/vendor
>/opt/rakudo-pkg/share/perl6/core
>CompUnit::Repository::AbsolutePath<4639587332824>
>CompUnit::Repository::NQP<4639586267208>
>CompUnit::Repository::Perl5<4639586267248>
> at /home/CDs/Windows/NtUtil/WinMessageBox.pm6:50
> 
> $ which NativeConvert.pm6
> ./NativeConvert.pm6
> and three other pm.6's WinMessageBox imports.
> 
> I can only compile check my modules if I
> import them to a program and -c the program.
> 
> For example, the following program uses
> the above module:
>$ raku -c CobianWrapper.pl6
>Syntax OK
> 
> I just want to do a syntax check on my modules
> at time without the program.
> 
> :'(

The wrapper program can be a `-e` one-liner, like:
raku -c -e 'use NativeCall;'
Syntax OK

Does this work for you?
raku -c -e 'use WinMessageBox;'

-- 
Hope this helps,
Bruce Gray (Util of PerlMonks)



Re: -c question

2024-02-06 Thread Elizabeth Mattijsen
Do you have some "use lib 'foo'" setting in your program?

If so, use that on the command-line, e.g.:

$ raku -Ifoo -c bar.rakumod

> On 6 Feb 2024, at 17:52, ToddAndMargo via perl6-users  
> wrote:
> 
>>> On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users 
>>>  wrote:
>>> 
>>> Hi All,
>>> 
>>> Is there a way to syntax a module?  Sort of like the "-c"
>>> option on main programs?
>>> 
>>> Many thanks,
>>> -T
> 
> On 2/6/24 01:34, Elizabeth Mattijsen wrote:
> > $ raku -c foo.rakumod
> > Syntax OK
> >
> 
> $ raku -c WinMessageBox.pm6
> ===SORRY!=== Error while compiling /home/CDs/Windows/NtUtil/WinMessageBox.pm6
> Could not find NativeConvert in:
>/home/tony/.raku
>/opt/rakudo-pkg/share/perl6/site
>/opt/rakudo-pkg/share/perl6/vendor
>/opt/rakudo-pkg/share/perl6/core
>CompUnit::Repository::AbsolutePath<4639587332824>
>CompUnit::Repository::NQP<4639586267208>
>CompUnit::Repository::Perl5<4639586267248>
> at /home/CDs/Windows/NtUtil/WinMessageBox.pm6:50
> 
> $ which NativeConvert.pm6
> ./NativeConvert.pm6
> and three other pm.6's WinMessageBox imports.
> 
> I can only compile check my modules if I
> import them to a program and -c the program.
> 
> For example, the following program uses
> the above module:
>$ raku -c CobianWrapper.pl6
>Syntax OK
> 
> I just want to do a syntax check on my modules
> at time without the program.
> 
> :'(



Re: -c question

2024-02-06 Thread ToddAndMargo via perl6-users

On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users  
wrote:

Hi All,

Is there a way to syntax a module?  Sort of like the "-c"
option on main programs?

Many thanks,
-T


On 2/6/24 01:34, Elizabeth Mattijsen wrote:
> $ raku -c foo.rakumod
> Syntax OK
>

$ raku -c WinMessageBox.pm6
===SORRY!=== Error while compiling 
/home/CDs/Windows/NtUtil/WinMessageBox.pm6

Could not find NativeConvert in:
/home/tony/.raku
/opt/rakudo-pkg/share/perl6/site
/opt/rakudo-pkg/share/perl6/vendor
/opt/rakudo-pkg/share/perl6/core
CompUnit::Repository::AbsolutePath<4639587332824>
CompUnit::Repository::NQP<4639586267208>
CompUnit::Repository::Perl5<4639586267248>
at /home/CDs/Windows/NtUtil/WinMessageBox.pm6:50

$ which NativeConvert.pm6
./NativeConvert.pm6
and three other pm.6's WinMessageBox imports.

I can only compile check my modules if I
import them to a program and -c the program.

For example, the following program uses
the above module:
$ raku -c CobianWrapper.pl6
Syntax OK

I just want to do a syntax check on my modules
at time without the program.

:'(


Re: -c question

2024-02-06 Thread Elizabeth Mattijsen
$ raku -c foo.rakumod
Syntax OK

> On 6 Feb 2024, at 00:39, ToddAndMargo via perl6-users  
> wrote:
> 
> Hi All,
> 
> Is there a way to syntax a module?  Sort of like the "-c"
> option on main programs?
> 
> Many thanks,
> -T
> 
> 
> 
> -- 
> ~~
> Computers are like air conditioners.
> They malfunction when you open windows
> ~~



Re: IO::Socket::INET timeout?

2024-01-21 Thread Paul Procacci
On Sat, Jan 20, 2024 at 5:02 PM William Michels 
wrote:

> Hi Paul,
>
> Did you get any resolution on this? I've only found these links:
>
> https://docs.raku.org/type/IO/Socket/INET
>
>
> https://stackoverflow.com/questions/72639883/how-to-deal-with-exceptions-in-iosocketinet
>
> I imagine a solution is possible using a Supply, but I haven't gotten
> there yet:
>
> https://docs.raku.org/type/Supply
>
> Best, Bill.
>
>
> On Jan 8, 2024, at 18:06, Paul Procacci  wrote:
>
> Hey all,
>
> What's the right way to specify a timeout for an IO::Socket::INET?
>
> What I have:
> $!socket := IO::Socket::INET.new(:host($!server), :port($!port));
>
> What I'd like to do which isn't possible:
> $!socket := IO::Socket::INET.new(:host($!server), :port($!port),
> :timeout($!timeout);
>
> Can your suggestion apply to reads/writes as well?
> To further this, I've reading on Promises and Supply's and have found
> suggestions that only Supply's can capture errors and whatnot, etc.
>
> I'm not sure what to make if anything I've read.  Does anyone have a clear
> example of connecting a socket, and reading/writing to that socket with
> timeouts?
>
> Thanks,
> Paul Procacci
>
>
> --
> __
>
> :(){ :|:& };:
>
>
>
Hey William,

I haven't made any progress.  I have enough things going on that I can
afford to put it aside for a while and then circle back to this in a bit.
If you find out, please let us know!  I too think Supply is the way forward
here.

~Paul
-- 
__

:(){ :|:& };:


  1   2   3   4   5   6   7   8   9   10   >