Re: I need one liner module import help

2019-06-12 Thread Bruce Gray



> On Jun 12, 2019, at 1:22 AM, ToddAndMargo via perl6-users 
>  wrote:
—snip--
> $ perl6 -I /home/linuxutil/p6lib -M PrintColors::PrintBlue -e 'PrintBlue( 
> "Blue\n" );'
> ===SORRY!===
> Could not find PrintColors::PrintBlue at line 1 in:

I see that I introduced a point of confusion.

In Perl 5 and Perl 6, double-colons are a namespace separator.
The module Audio::Taglib::Simple is a single module, but can be thought of as 
"the Simple module, of possibly-a-bunch-of Taglib modules, of the overall 
family of Audio modules".
In the same way, my name is "Bruce Gray" and I am an individual, but can be 
thought of as "the Bruce person, of the Gray family".
This is all less evident when browsing modules.perl6.org than Perl 5's CPAN, 
because the CPAN sheriffs pressure its module authors to use multi-level 
naming, and modules.perl6.org is more of the Wild West where single-level 
naming (Balidor, CCChart, ECMA262Regex, ScaleVec) is common.
( My talk on variable namespaces is "The Why of My()": 
https://www.youtube.com/watch?v=SA4mUs3Ro98 )

All that to say, that of all the ways Perl 6 or Rakudo might intend us to 
indicate the arguments to a `use` statement in a one-liner, I am sure that way 
cannot ever be with a double-colon.
I was using double-colon in my made-up module names just because I thought it 
would be clearer; to my Perl 5 eyes, Foo::Bar::Baz is always a module name.

The fact that a single leading colon designates a import tag (or "group") 
further clouds the issue.

-- 
Bruce Gray (Util of PerlMonks)


Re: replace s///r ?

2019-06-12 Thread William Michels via perl6-users
Thank you Yary. It's not often I have to prepend a "4" to a mixed list
items of containing numbers, but your code is perfect for extracting
the numbers and prepending a dollar sign ($):

>  .say for (325, '44a', 555, 6).grep(/^\d+$/).map( '$' ~ * )
$325
$555
$6

Best Regards,

Bill.



On Mon, Jun 10, 2019 at 11:02 PM yary  wrote:
>
> Or if you need to "map" the substitution
>
> .say for (325, '44a', 555, 6).grep(/^\d+$/).map( *.subst(/^/,4) )
>
>
> -y
>
> On Mon, Jun 10, 2019 at 10:54 PM yary  wrote:
> >
> > p6 can transliterate from p5 rather literally
> >
> > say .subst(/^/,4) for grep /^\d+$/, (325, '44a', 555, 6);
> >
> >
> >
> > -y
> >
> > -y
> >
> >
> > On Mon, Jun 10, 2019 at 9:19 PM Marc Chantreux
> >  wrote:
> > >
> > > hello people,
> > >
> > > in perl5, i can
> > >
> > > print for
> > > map  s/^/4/r,
> > > grep /^\d+$/,
> > > 
> > >
> > > the perl6 version is a Seq, so much more memory friendly
> > > but i expected (and haven't found in the documentation)
> > > a short equivalent of s///r so the shorter i have is:
> > >
> > > $*ARGFILES
> > >  . lines
> > >  . grep( / ^ + $ / )
> > >  .  map( *.subst(/^/," * ") )
> > >  .  map(&other-things-to-do)
> > >  .  map(&say)
> > >
> > > when, of course, i want to replace
> > >
> > >  .  map( *.subst(/^/," * ") )
> > >
> > > by something like
> > >
> > >  .  map( s:r/^/* / )
> > >
> > > any idea?
> > >
> > > regards
> > > marc


Re: I need one liner module import help

2019-06-12 Thread ToddAndMargo via perl6-users

Hi Bruce,

This has to do with the way I am importing subs from modules.

When importing subs, I like to declare which subs I
am importing.  Otherwise my code is a nightmare to maintain.
"Where the heck did that subs comes from? Is its a system
subs or "


For instance, in  Perl 5:

use Term::ANSIColor qw ( BOLD BLUE RED GREEN RESET );

imports "BOLD BLUE RED GREEN RESET".


Perl 6 has improved on this with selective importing and exporting.
The ":" is part of the tag:

https://docs.perl6.org/language/modules#Exporting_and_selective_importing

For instance:

PrintColors.pm6 exports with:

sub PrintBlue  ( **@args ) is export( :PrintBlue )  { print 
color('bold'), color('blue'),  |@args, color('reset'); }


The tag is `is export( :PrintBlue )`


And imports with:

 use PrintColors :PrintRed, :PrintGreen, :PrintBlue, :PrintErr, 
:PrintRedErr, :PrintGreenErr, :PrintBlueErr;


What I am after is a way to run a one liner with
this type of export using the "-M" switch".

   perl6 -I /home/linuxutil/p6lib -M "PrintColors :PrintBlue" -e 
'PrintBlue( "Blue\n" );'


   Could not find PrintColors :PrintBlue at line 1 in:

-T


Re: I need one liner module import help

2019-06-12 Thread Tom Browder
On Wed, Jun 12, 2019 at 16:12 ToddAndMargo via perl6-users <
perl6-us...@perl.org> wrote:

> Hi Bruce,
>
> This has to do with the way I am importing subs from modules.
>
> When importing subs, I like to declare which subs I
> am importing.  Otherwise my code is a nightmare to maintain.
> "Where the heck did that subs comes from? Is its a system
> subs or "
>
>
> For instance, in  Perl 5:
>
>  use Term::ANSIColor qw ( BOLD BLUE RED GREEN RESET );
>
> imports "BOLD BLUE RED GREEN RESET".
>
>
> Perl 6 has improved on this with selective importing and exporting.
> The ":" is part of the tag:
>
> https://docs.perl6.org/language/modules#Exporting_and_selective_importing
>
> For instance:
>
> PrintColors.pm6 exports with:
>
>  sub PrintBlue  ( **@args ) is export( :PrintBlue )  { print
> color('bold'), color('blue'),  |@args, color('reset'); }
>
> The tag is `is export( :PrintBlue )`
>
> And imports with:
>
>   use PrintColors :PrintRed, :PrintGreen, :PrintBlue, :PrintErr,
> :PrintRedErr, :PrintGreenErr, :PrintBlueErr;
>
> What I am after is a way to run a one liner with
> this type of export using the "-M" switch".


I think you will have to file a Rakudo issue.

-Tom


Re: I need one liner module import help

2019-06-12 Thread ToddAndMargo via perl6-users

On 6/12/19 2:51 PM, Tom Browder wrote:

I think you will have to file a Rakudo issue.



Do you have a link to them?