in reply to Re^2: Illegal octal digit error
in thread Illegal octal digit error

Toward the end of the Comma Operator section in perlop it says:

If the argument on the left is not a word, it is first interpreted as an expression, and then the string value of that is used.

which is consistent with observed behaviour.


True laziness is hard work

Replies are listed 'Best First'.
Re^4: Illegal octal digit error
by ig (Vicar) on Jun 06, 2009 at 12:59 UTC

    In which case a word must be something other than a sequence of "word characters". Is word defined somewhere?

    update: I'm guessing a word must begin with an alphabetic character or an underscore so that anything beginning with a digit is not a word.

    update: Looking at perl source (toke.c) it appears that anything beginning with a digit is scanned as a number while anything starting with an underscore or alphabetic character other than 'v' or 'x' is scanned as... there are quite a few possibilities here, one of which is "a word before a => operator". There is some additional testing done for 'v' and 'x'. I don't follow it all, but suspect 'v' might be the start of a version string, handled somewhat differently, and 'x' followed by a digit might be a repeat operator, depending on context. Otherwise 'v' and 'x' are handled the same as all the other alphabetics.

    In conclusion: it appears that a word is not any sequence of word characters, but only those that begin with underscore or an alphabetic character. Anything beginning with a digit is a number, not a word, and is not forced to be a string when on the left of '=>'.