Skip Menu |
Report information
Id: 127344
Status: open
Priority: 0/
Queue: perl6

Owner: Nobody
Requestors: rick [at] hiranyaloka.com
Cc:
AdminCc:

Severity: (no value)
Tag: (no value)
Platform: (no value)
Patch Status: (no value)
VM: (no value)



Subject: fail to handle numbers as option name for MAIN
Download (untitled) / with headers
text/plain 102b
test.pl: sub MAIN (*%h) { %h.keys.say; }; then test.pl --foo=bar --42=bat returns (-42 foo) why -42?
Download (untitled) / with headers
text/plain 520b
On Thu Jan 21 23:32:42 2016, rick@hiranyaloka.com wrote: Show quoted text
> test.pl: > sub MAIN (*%h) { %h.keys.say; }; > > then test.pl --foo=bar --42=bat > returns (-42 foo) > > why -42?
The passed values are smart-matched against: /^ ( '--' | '-' | ':' ) ('/'?) (<-[0..9\.]> .*) $/ to capture $switch, $negate, and $arg. I don't understand why a leading digit or '.' are negated here. It would be nice to allow digits in options. But if that's necessary, then adding a hyphen in that character class will fix the "-42" result.
Download (untitled) / with headers
text/plain 456b
Question for @LARRY: how are we resolving this? Do we allow digits as named params or do we fix it to reject the -42 edge case too? My vote would be to allow them, as it gives for greater functionality. I don't know why this restriction was added, but I suspect it may have been due to inability to name a variable starting with a digit, however, such parameters can still be accessed via %_ or a slurpy hash. -- Cheers, ZZ | https://twitter.com/zoffix


This service is sponsored and maintained by Best Practical Solutions and runs on Perl.org infrastructure.

For issues related to this RT instance (aka "perlbug"), please contact perlbug-admin at perl.org