This is unintuitive:

  perl -e 'print "> "; while(<>) {print(( eval $_ )[-1], "\n> ")}'

... then enter 2*012.  It prints "20".  2*12 is obviously 24, but perl's
interpreting that "012" as octal.  We sometimes have our numbers zero padded
to make the columns line up, they're not octal.

Is there any way to keep perl's eval from interpreting numbers starting with
"0" as octal?

I tried to regex them out but that regex is tricky since I'm writing a
custom calculator, and I have no idea what the user might enter.

TIA.

Bryan



-- 
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to