You have misunderstood. The reason you can do that in Perl 5 is because
Term/ANSIColor.pm starts with

    package Term::ANSIColor;

It has nothing to do with what you named the file, it is a matter of
namespaces. And Perl 5 and Perl 6 behave mostly the same here (Perl 6 has a
few more options). Neither one will create a new namespace just because you
stuck something in a different file; you must in both cases specify the
namespace ("package: in Perl 5, "unit module" in Perl 6).

On Sun, Jun 3, 2018 at 7:17 PM ToddAndMargo <toddandma...@zoho.com> wrote:

>
> On 0>> On Sun, Jun 3, 2018 at 6:33 PM ToddAndMargo <toddandma...@zoho.com
> >> <mailto:toddandma...@zoho.com>> wrote:
> >>
> >>     On 06/03/2018 03:24 PM, Brandon Allbery wrote:
> >>      > It is allowed if you have 'unit module RunNoShell;' at the top of
> >>      > RunNoShell.pm6. Otherwise you defined it in the main namespace
> and
> >>      > looking for it in the RunNoShell namespace will fail.
> >>      >
> >>      > Perl 5 does the same thing fi you omitted 'package RunNoShell;'
> >>     at the
> >>      > top of RunNoShell.pm.
> >>      >
> >>
> >>     The name of the file is `RunNoShell.pm`
> >>
> >>     It has two exported subs:
> >>            sub RunNoShellErr ( $RunString ) is export
> >>            sub RunNoShell ( $RunString ) is export
> >>
> >>     If I place
> >>            unit module RunNoShell;
> >>
> >>     at the top, what happens?
> >>           All subs get exported?
> >>           Do I have to import them differently
> >>
> >>
> >> What happens is your two subs get the full names
> >>
> >>      RunNoShell::RunNoShellErr
> >>      RunNoShell::RunNoShell
> >>
> >> Without those lines, their full names are
> >>
> >>      MAIN::RunNoShellErr
> >>      MAIN::RunNoShell
>
> 6/03/2018 03:54 PM, Brandon Allbery wrote:
> >
> > Since you are explicitly running RunNoShell::RunNoShell, you get an
> > error with the second because there is no sub by that name.
> >
> > Again, this is no different from Perl 5 if you forget to include
> > 'package RunNoShell;' And this matters only in the case where you
> > explicitly asked for RunNoShell::RunNoShell instead of just RunNoShell,
> > which importing handles for you.
>
>
> My main reason for wanting to know this is for maintaining my
> code.
>
> In Perl 5
>      use Term::ANSIColor qw ( BOLD BLUE RED GREEN RESET );
>
> I can do a simple search to figure our where the heck
> (may not be my "actual" word) `BOLD` came from.
>
> If I want to doubly make sure I know where things came from,
> I can write
>        Term::ASNIColor::BOLD
>
> I have no such option in Perl 6 to do this.  This is the ONLY
> thing I like better in p5 that is better than p6.  (Perl 5's
> sub declarations are a nightmare.)
>
> So I am looking for a substitute way of doing this.  So
> back to my original question:
>
>
> The name of the file is `RunNoShell.pm`
>
> It has two exported subs:
>       sub RunNoShellErr ( $RunString ) is export
>       sub RunNoShell ( $RunString ) is export
>
> If I place
>       unit module RunNoShell;
>
> at the top, what happens?
>      All subs get exported?
>      Do I have to import them differently
>
>             Old way:
>                 use RunNoShell;  # qx[ RunNoShell ];
>


-- 
brandon s allbery kf8nh                               sine nomine associates
allber...@gmail.com                                  ballb...@sinenomine.net
unix, openafs, kerberos, infrastructure, xmonad        http://sinenomine.net

Reply via email to