in reply to Hash table key names with a minus
Valid unquoted strings, such as bare literal hash keys, consist of \w characters only. They are: A-Za-z0-9 and underscore (_). You can have leading or trailing whitespace, which can come in handy. Hoewever, the - character is not allowed, and forces it to be a normal expression.
Without strict, it's allowed, because without strict it's allowed to use unquoted strings everywhere, not only in literal hash keys and the left operand of the => operator.
Consider:# Assuming you don't have subs called POWER and/or NODE. no strict; $run{POWER-NODE} = yes; # equals: $run{ 'POWER' - 'NODE' } = 'yes'; # equals: $run{ 0 - 0 } = 'yes'; # and thus: $run{0} = 'yes';
$foo{99-24} = "Hello, world!\n"; print $foo{75};
U28geW91IGNhbiBhbGwgcm90MTMgY
W5kIHBhY2soKS4gQnV0IGRvIHlvdS
ByZWNvZ25pc2UgQmFzZTY0IHdoZW4
geW91IHNlZSBpdD8gIC0tIEp1ZXJk
|
|---|