Skip to content

Instantly share code, notes, and snippets.

@tadzik
Created April 21, 2016 10:51
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tadzik/876ad5e3e01819f08e1cb724b7de3d8a to your computer and use it in GitHub Desktop.
Save tadzik/876ad5e3e01819f08e1cb724b7de3d8a to your computer and use it in GitHub Desktop.
┌─[tadzik@yavin]─[~/.rakudobrew/moar-nom] (remotes/origin/HEAD)*
└─[%]─> perl6 test.pl --named1 positional1 --named2 positional2 --named3
["positional1", "--named2", "positional2", "--named3"]
{:named1}
┌─[tadzik@yavin]─[~/.rakudobrew/moar-nom] (remotes/origin/HEAD)*
└─[%]─> g diff src/core/Main.pm
diff --git a/src/core/Main.pm b/src/core/Main.pm
index cbbd835..4c7a066 100644
--- a/src/core/Main.pm
+++ b/src/core/Main.pm
@@ -32,9 +32,8 @@ my sub MAIN_HELPER($retval = 0) {
%named-arguments.push: $arg => !$negate;
}
} else {
- @args.unshift($passed-value) unless $passed-value eq '--';
- @positional-arguments.append: @args.map: &val;
- last;
+ last if $passed-value eq '--';
+ @positional-arguments.push: $passed-value;
}
}
@positional-arguments, %named-arguments;
┌─[tadzik@yavin]─[~/.rakudobrew/moar-nom] (remotes/origin/HEAD)*
└─[%]─> ./perl6 test.pl --named1 positional1 --named2 positional2 --named3
["positional1", "positional2"]
{:named1, :named2, :named3}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment