sub RUN-MAIN

Documentation for sub RUN-MAIN assembled from the following types:

language documentation Command line interface

From Command line interface

(Command line interface) sub RUN-MAIN

Defined as:

sub RUN-MAIN(&main$mainline:$in-as-argsfiles)

This routine allows complete control over the handling of MAIN. It gets a Callable that is the MAIN that should be executed, the return value of the mainline execution and additional named variables: :in-as-argsfiles which will be True if STDIN should be treated as $*ARGFILES.

If RUN-MAIN is not provided, a default one will be run that looks for subroutines of the old interface, such as MAIN_HELPER and USAGE. If found, will execute following the "old" semantics.

class Hero {
    has @!inventory;
    has Str $.name;
    submethod BUILD:$name:@inventory ) {
        $!name = $name;
        @!inventory = @inventory
    }
}
 
sub new-main($name*@stuff ) {
    Hero.new(:name($name), :inventory(@stuff) ).perl.say
}
 
RUN-MAIN&new-mainNil );

This will print the name (first argument) of the generated object.