Skip to content

Instantly share code, notes, and snippets.

@zoffixznet
Created April 27, 2016 17:08
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 zoffixznet/f95da0224c863dd4d014f39539c6be24 to your computer and use it in GitHub Desktop.
Save zoffixznet/f95da0224c863dd4d014f39539c6be24 to your computer and use it in GitHub Desktop.
BEGIN my $JSON = q:to/END/;
{
"name": "Bender",
"input": "beer"
}
END
multi sub trait_mod:<is> (Variable $v, :$config!) {
my $conf = from-json $JSON;
my $name = $v.var.VAR.name.substr: 1;
$v.var = $conf{ $name } // die 'Unknown configuration variable';
}
my $name is config;
say $name;
my $input is config;
say $input;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment