in reply to Re^2: Clarifying the Comma Operator (bareword)
in thread Clarifying the Comma Operator
Actually, that's where the problem lies: 08 is not seen as a string but (wrongly) as an octal number. Perl tries to numify this "word" whereas it should be stringified.But how should perl know? perl is tokenizing when it encounters the leading 0. Considering that it know it's now expecting a TERM, the leading 0 must mean it's going to encounter an octal number. It doesn't know about the following arrow yet, but it has to decide how to tokenize the next thing.
And that's why all "bare words" look like identifiers. When encountering
perl is expecting a TERM. Barewords can start terms (infix operators like the x tye mentions cannot - that's why infix operators can consist of letters, but prefix operators cannot), and that's why all barewords look like identifiers. Because only after tokenizing the bareword and looking at the next token, perl decides whether the bareword is an identifier (subroutine, filehandle), or a string.foo::bar => baz
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^4: Clarifying the Comma Operator (bareword)
by CountZero (Bishop) on Jun 07, 2009 at 17:22 UTC |