# New Ticket Created by  Christopher Bottoms 
# Please include the string:  [perl #84342]
# in the subject line of all future correspondence about this issue. 
# <URL: http://rt.perl.org/rt3/Ticket/Display.html?id=84342 >


SHORT VERSION (notice lack of output when file is run):

$ cat lib/A.pm
use v6;
module A;

our sub MAIN ( $filename ) {
    say "Preparing to process '$filename'";
}

$ lib/A.pm
$ lib/A.pm foo.txt


LONG VERSION:
I would like to make what brian d foy calls a 'modulino', a module
that can act as a program or as a module. This makes
Test-Driven-Development much easier, as you can test it like a module
but run it like a program.

However, using the 'module' keyword makes it cease working as a program.

Without the 'module' keyword, the following works fine as a program,
but not as a module. (I really like the automatically generated usage
message, by the way).

$ cat lib/A.pm
use v6;

our sub MAIN ( $filename ) {
    say "Preparing to process '$filename'";
}

$ lib/A.pm foo.txt
Preparing to process 'foo.txt'

$ lib/A.pm
Usage:
lib/A.pm filename

shell returned 29


Then with the keyword 'module', it doesn't work right. Notice the lack
of a usage message and the lack of output.

$ cat lib/A.pm
use v6;
module A;

our sub MAIN ( $filename ) {
    say "Preparing to process '$filename'";
}

$ lib/A.pm
$ lib/A.pm foo.txt


Thanks,
Christopher Bottoms (molecules)

Reply via email to