in reply to Re^2: What does "-" in a use statement do?
in thread What does "-" in a use statement do?

Nowhere in use does it say that the LIST should be a list of identifiers.

If you read the documentation of App::Cmd::Setup, I presume that there it will also not talk about a list of identifiers that get exported, especially no identifier named -app.

If you further read use (and the associated require) you will find that one of the things that use does is call a subroutine import if it exists. And that subroutine is called with all the parameters from the LIST part of the use statement.

What that import subroutine does depends on the module. If the module uses the import subroutine from Exporter like the following:

use Exporter 'import';

... then it will get the behaviour you seem to expect, of exporting subroutine names and variable names on demand.

But most likely, App::Cmd::Setup does something different.

Replies are listed 'Best First'.
Re^4: What does "-" in a use statement do?
by nysus (Parson) on Jan 27, 2018 at 14:25 UTC

    Ah, got it. So basically, the list passed to use can be used for just about anything, not just importing code. In this case, App::Cmd::Setup is just using it to identify what the package is (a command or an app) and to be able to pass in variables. Very interesting. Thanks!

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

Re^4: What does "-" in a use statement do?
by nysus (Parson) on Jan 27, 2018 at 14:41 UTC

    Do you happen to know if here is there is an agreed upon word for describing how the -app bit is used? Perhaps something like "package initializer"?

    $PM = "Perl Monk's";
    $MCF = "Most Clueless Friar Abbot Bishop Pontiff Deacon Curate Priest";
    $nysus = $PM . ' ' . $MCF;
    Click here if you love Perl Monks

      ... an agreed upon word for describing how the -app bit is used?

      If something like  -app appeared in the parameter list of a command-line utility, it would be called a "switch" because it would most likely alter the behavior of the utility, e.g., by switching some behavior on or off. I and, I think, most others would be comfortable describing  -app as a switch controlling the behavior of the App::Cmd::Setup module. Update: See "switch" and also "options" and "flag" in perlglossary.


      Give a man a fish:  <%-{-{-{-<

        ++ Adding: some folks calls them flags instead of switches. And some folks use them interchangeable or limit switch to boolean (on|off) options and use flags for those taking a value.