blob: a2afe90d4e499b785d89393dfaa7569e343e3f67 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
|
# Create a script to demonstrate creating dynamic variable name, assign a value
# to the variable and finally print the variable. The variable name would be
# passed as command line argument.
# Example usage:
#
# > perl6 ch2.p6 my_var 37
# $my_var = 37
#
sub MAIN($name, $value) {
GLOBAL::{'$' ~ $name} = $value;
say '$' ~ $name ~ " = " ~ GLOBAL::{'$' ~ $name};
}
|