[Israel.pm] Direct access to variables from sub

Gaal Yahas gaal at forum2.org
Sun Oct 2 06:51:48 PDT 2005

On Sun, Oct 02, 2005 at 04:08:18PM +0300, Levenglick Dov-RM07994 wrote:
> This is the first time I hear of this magical + operator. What exactly
> does it do and where can I find the proper documentation (incomprehensible
> code == job security)

Unary plus is not that magical, it's just syntactic disambiguation. It's
unary minus you should be wary of (or happy for, if on a hunt for job
security). From L<perlop/"Symbolic Unary Operators">:

    Unary "-" performs arithmetic negation if the operand is numeric.
    If the operand is an identifier, a string consisting of a minus
    sign concatenated with the identifier is returned.  Otherwise,
    if the string starts with a plus or minus, a string starting with
    the opposite sign is returned.  One effect of these rules is that
    -bareword is equivalent to the string "-bareword". [...]

    Unary "+" has no effect whatsoever, even on strings.  It is useful
    syntactically for separating a function name from a parenthesized
    expression that would otherwise be interpreted as the complete list
    of function arguments.  (See examples above under "Terms and List
    Operators (Leftward)".)

Gaal Yahas <gaal at forum2.org>

More information about the Perl mailing list