in reply to Re: Print not printing
in thread Print not printing

Yes, but the mystery remains: why isn't this syntax invoked in the expression print $a + $b, which should be syntactically equivalent to print $a +$b.

the lowliest monk

Replies are listed 'Best First'.
Re^3: Print not printing
by rev_1318 (Chaplain) on Jun 24, 2005 at 07:43 UTC
    It seems this is one of those rare occasions where white space does matter. The parser has to take a guess at what +$b is supposed to be and guesses that a unary + is used. Bug or feature? Depends on how you look at it, I guess :)

    Paul

      It's a beature! No, a fug!

Re^3: Print not printing
by CountZero (Bishop) on Jun 24, 2005 at 07:52 UTC
    As already said, there is room for ambiguity in this syntax. So although whitespace should not be relevant, it is used to disambiguate things.

    It really is a Perl DWIM thing.

    By putting a space before the + and not behind it, you seem to hint to Perl that the + is now a unary plus and automagically the $a now becomes a filehandle.

    CountZero

    "If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law