G'day ic23oluk,
I see you've been given lots of advice on how to handle that specific character.
From your question, it appears that you may be attempting to hard-code each character and ASCII value. That's a lot of effort, and quite unnecessary, for your stated task: "ascii signs as keys, and the corresponding numbers as values". You can do that with a single statement:
my %hash = map { chr $_ => $_ } 32 .. 126;
That will give you a table of all, printable, 7-bit ASCII characters and their corresponding decimal values. You can test it like this:
$ perl -e 'use Data::Dump; my %h = map { chr $_ => $_ } 32 .. 126; dd +\%h' { " " => 32, "!" => 33, "\"" => 34, ... "|" => 124, "}" => 125, "~" => 126, }
Take a look at sprintf, if you want to format the values as hexadecimal, Unicode code points, HTML entity references, or something else. For example,
$ perl -e 'use Data::Dump; my %h = map { chr $_ => sprintf "U+%04X", $ +_ } 32 .. 126; dd \%h' { " " => "U+0020", "!" => "U+0021", "\"" => "U+0022", ... "|" => "U+007C", "}" => "U+007D", "~" => "U+007E", }
[Aside: I'm guessing English isn't your first language. The word you were looking for in your OP is "assign" ('n' and 'g' order reversed). The word "assing" means something else: I'll leave you to follow that link if want a chuckle. :-)]
— Ken
In reply to Re: quotation mark as key
by kcott
in thread quotation mark as key
by ic23oluk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |