Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:

on the command line the -0octal syntax does that mean I can use: octal: 012 is ! do I have to have the extra 0? perl -e0012 stuff....

Replies are listed 'Best First'.
Re: perl -e0octal
by Hofmator (Curate) on Aug 21, 2001 at 20:35 UTC

    Have you tried it?? Here goes

    % perl -012 -e 'print ord $/' % perl -0012 -e 'print ord $/'
    both versions print 10. Watch out though how you cluster your switches, -e has to be last in a cluster or alone!

    Watch out for the special cases of

    % perl -00 # paragraph mode % perl -0777 # slurp mode

    -- Hofmator

Re: perl -e0octal
by dga (Hermit) on Aug 21, 2001 at 20:13 UTC

    Perl treats literals coded into your program with a leading 0 specially.

    perl -e '$a=017; $b=0x17; print "$a $b\n";' 15 23

    The first number which is treated as octal is 15 in decimal and the second is treated as hexidecimal and so is 23 decimal.