Skip to content

Instantly share code, notes, and snippets.

@treyharris
Last active June 21, 2019 22:05
Show Gist options
  • Save treyharris/eba1752c6a59a17fb570dbfbfb236ef0 to your computer and use it in GitHub Desktop.
Save treyharris/eba1752c6a59a17fb570dbfbfb236ef0 to your computer and use it in GitHub Desktop.
The minimal working CLI
#!/usr/bin/env perl6
## To get a MAIN to run in a unit module/package:
unit module My-Modules-Script;
## You must have the `is export` here; `our` will not work
sub MAIN($x) is export {
say "This is the module's MAIN called with $x";
}
## And you must call it differently:
# $ ./My-Modules-Script.pm6
# $ ./My-Modules-Script.pm6 22
# $ perl6 -M My-Modules-Script -e ''
# Usage:
# -e '...' <x>
# $ perl6 -M My-Modules-Script -e '' 42
# This is the module's MAIN called with 42
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment