> On Jun 11, 2019, at 5:39 PM, ToddAndMargo via perl6-users 
> <perl6-us...@perl.org> 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<foo bar>;
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)

Reply via email to