in reply to Re: Re: Confused about unary +
in thread Confused about unary +

I think the point is that this use of unary + to disambiguate various forms of syntax is:

Reading that back, I'm not at all sure that this explanation is any clearer than those that preceed it, or even that it is completely correct, but it made sense as I typed it:)

Just to add another one to your list

@_ = 'world!'; my %hash; $hash{ shift } = 'Hello'; $hash{ +shift } = 'Goodbye'; print "$k => $v\n" while my($k, $v) = each %hash; # prints shift => 'Hello' world! => 'Goodbye'

In this case using shift() instead of +shift would have served to force the compiler to treat shift as an term (and therefore a function as there is no sigil) rather than as a (splendid) bareword string as in the first line above.


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller
If I understand your problem, I can solve it! Of course, the same can be said for you.