in reply to Re: Why does this code think I'm trying to use symbolic references?
in thread Why does this code think I'm trying to use symbolic references?

print $n ... expects $n to contain a file handle.

But print $n + 4; doesn't; and that was my intent. And in (almost, if not) all other circumstances $n +4 and $n + 4 are equivalent, so It just didn't click even after I found that adding another space fixed the problem.

As I'm normally quite prodigious with my horizontal whitespace, it's just not something I've encountered before.


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority". I knew I was on the right track :)
In the absence of evidence, opinion is indistinguishable from prejudice. Not understood.

Replies are listed 'Best First'.
Re^3: Why does this code think I'm trying to use symbolic references?
by AnomalousMonk (Archbishop) on Jun 12, 2016 at 22:58 UTC
    ... I'm normally quite prodigious with my horizontal whitespace ...

    Either prodigality or parsimony seem to work; e.g.,  print $n+4; also avoids the problem. Apparently it's only  $n +4 that Perl looks at and says "Oh, of course: a unary plus!" (I haven't tested it, but I assume the same would happen | I've tested it, and the same thing happens with a pseudo-unary minus.)

    Update: Per perlop, unary + and - have higher precedence than the binary operators.


    Give a man a fish:  <%-{-{-{-<