Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fail to handle numbers as option name for MAIN #5077

Open
p6rt opened this issue Jan 22, 2016 · 4 comments
Open

fail to handle numbers as option name for MAIN #5077

p6rt opened this issue Jan 22, 2016 · 4 comments
Labels
at_larry RFC Request For Comments

Comments

@p6rt
Copy link

p6rt commented Jan 22, 2016

Migrated from rt.perl.org#127344 (status was 'open')

Searchable as RT127344$

@p6rt
Copy link
Author

p6rt commented Jan 22, 2016

From rick@hiranyaloka.com

test.pl​:
sub MAIN (*%h) { %h.keys.say; };

then test.pl --foo=bar --42=bat
returns (-42 foo)

why -42?

@p6rt
Copy link
Author

p6rt commented Jan 23, 2016

From rick@hiranyaloka.com

On Thu Jan 21 23​:32​:42 2016, rick@​hiranyaloka.com wrote​:

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.

@p6rt
Copy link
Author

p6rt commented Jul 8, 2016

@coke - Status changed from 'new' to 'open'

@p6rt
Copy link
Author

p6rt commented Aug 6, 2016

From @zoffixznet

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

@p6rt p6rt added at_larry RFC Request For Comments labels Jan 5, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
at_larry RFC Request For Comments
Projects
None yet
Development

No branches or pull requests

1 participant