Re: replace s///r ?
The /r modifier on s/// in Perl5 is S/// in Perl6. Though you have to put it into a block lambda, otherwise it applies to $_ before it gets a chance to be passed to map. $*ARGFILES . lines . grep( / ^ + $ / ) . map( {S/^/ * /} ) . map(&other-things-to-do) . map(&say) On Mon, Jun 10, 2019 at 11: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: replace s///r ?
hello, On Tue, Jun 11, 2019 at 08:26:11AM -0500, Brad Gilbert wrote: > The /r modifier on s/// in Perl5 is S/// in Perl6. oops .. it was the section just after s/// :( thanks for pointing out. > Though you have to put it into a block lambda, otherwise it applies to > $_ before it gets a chance to be passed to map. this is very kind to let perl5 win sometimes :) regards marc
I need one liner module import help
Hi All, I need one liner help importing a module sub This works: perl6 -e 'use lib "/home/linuxutil/p6lib"; use PrintColors :PrintBlue; PrintBlue( "Blue\n" );' Blue This does not: perl6 -I /home/linuxutil/p6lib -M "PrintColors :PrintBlue" -e 'PrintBlue( "Blue\n" );' Could not find PrintColors :PrintBlue at line 1 in: What did I do wrong, this time? Many thanks, -T
Re: I need one liner module import help
> On Jun 11, 2019, at 5:39 PM, ToddAndMargo via perl6-users > wrote: > > Hi All, > > I need one liner help importing a module sub > > This works: > > perl6 -e 'use lib "/home/linuxutil/p6lib"; use PrintColors :PrintBlue; > PrintBlue( "Blue\n" );' > > Blue > > > > This does not: > > perl6 -I /home/linuxutil/p6lib -M "PrintColors :PrintBlue" -e 'PrintBlue( > "Blue\n" );' > > Could not find PrintColors :PrintBlue at line 1 in: > > > > What did I do wrong, this time? > > Many thanks, > -T Results of my research: In Perl 5, the code to use a module *and* select its imports, use This::Module qw; can rephrased in a one-liner as: -MThis::Module=foo,bar The Perl 6 docs show a one-liner option for `use`: -M This::Module , but shows no version that lets you select the import. In src/Perl6/World.nqp, method do_pragma_or_load_module has code to start 'Performing imports' right after loading the module. (you can see the progress by setting RAKUDO_MODULE_DEBUG, as in `RAKUDO_MODULE_DEBUG=1 perl6 -MTest -e 'say 42'`) I see no tests exercising this part of the code, and when I experiment, any deviation I can think to try from `-M FooModule` results in failure in self.load_module, as whatever should recognize some divider between ModuleName and ModuleImportList fails to do so, so `-MFoo=Bar` tries to load a module with the 7-char name "Foo=Bar". Based on the call to `self.do_import`, I think that Rakudo is intended to support something like `-MThis::Module=foo,bar`, but I cannot tell what exact form the import separator should take, so cannot tell if we are just missing the correct syntax, or if there is a bug in Rakudo. Either way, there are docs and tests that need to be added. EOUTOFTIME, this email stands alone, no bugs filed. — Bruce Gray (Util of PerlMonks)
Re: I need one liner module import help
On 6/11/19 9:11 PM, Bruce Gray wrote: On Jun 11, 2019, at 5:39 PM, ToddAndMargo via perl6-users wrote: Hi All, I need one liner help importing a module sub This works: perl6 -e 'use lib "/home/linuxutil/p6lib"; use PrintColors :PrintBlue; PrintBlue( "Blue\n" );' Blue This does not: perl6 -I /home/linuxutil/p6lib -M "PrintColors :PrintBlue" -e 'PrintBlue( "Blue\n" );' Could not find PrintColors :PrintBlue at line 1 in: What did I do wrong, this time? Many thanks, -T Results of my research: In Perl 5, the code to use a module *and* select its imports, use This::Module qw; can rephrased in a one-liner as: -MThis::Module=foo,bar The Perl 6 docs show a one-liner option for `use`: -M This::Module , but shows no version that lets you select the import. In src/Perl6/World.nqp, method do_pragma_or_load_module has code to start 'Performing imports' right after loading the module. (you can see the progress by setting RAKUDO_MODULE_DEBUG, as in `RAKUDO_MODULE_DEBUG=1 perl6 -MTest -e 'say 42'`) I see no tests exercising this part of the code, and when I experiment, any deviation I can think to try from `-M FooModule` results in failure in self.load_module, as whatever should recognize some divider between ModuleName and ModuleImportList fails to do so, so `-MFoo=Bar` tries to load a module with the 7-char name "Foo=Bar". Based on the call to `self.do_import`, I think that Rakudo is intended to support something like `-MThis::Module=foo,bar`, but I cannot tell what exact form the import separator should take, so cannot tell if we are just missing the correct syntax, or if there is a bug in Rakudo. Either way, there are docs and tests that need to be added. EOUTOFTIME, this email stands alone, no bugs filed. — Bruce Gray (Util of PerlMonks) $ perl6 -I /home/linuxutil/p6lib -M PrintColors::PrintBlue -e 'PrintBlue( "Blue\n" );' ===SORRY!=== Could not find PrintColors::PrintBlue at line 1 in: