produces the error:#!/usr/bin/perl use charnames ":alias" => { map { $_ => $char++ } 'first character', 'second character', 'third character' }; printf "First: %X; third: %X\n", ord("\N{first character}"), ord("\N{third character}");
So it accepts the syntax of the alias setup, but doesn't actually create the aliases.Unknown charname 'first character' at ./mytest line 10, within string Execution of ./mytest aborted due to compilation errors.
If you're suggesting I use your assignment statement as written and then use your $characters variable to do the alias setup, I can't even find the right syntax for that. This gives syntax errors on the use charnames line, as I would expect (as did a couple variants I tried):
#!/usr/bin/perl $characters = { map { $_ => $char++ } 'first character', 'second character', 'third character' }; use charnames ":alias" => $characters;
In reply to Re^2: create an anonymous hash using "map"
by raygun
in thread create an anonymous hash using "map"
by raygun
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |