in reply to What does a plus mean before a package name?

I would guess that '+' means the return value of a_method_call will be interpreted as a number. Secondary effect should be that it prevents indirect object invocation of ok, but the writer could as well just have used parenthesis to get this effect without confusing everyone else.

At least thats my take, I might be wrong

  • Comment on Re: What does a plus mean before a package name?

Replies are listed 'Best First'.
Re^2: What does a plus mean before a package name?
by ikegami (Patriarch) on May 26, 2011 at 09:29 UTC

    Unary-"+" does not numify (or stringify). It's a no-op.

    >perl -E"$_ = 'abc'; say +$_;" abc >perl -E"$_ = [qw( a b c )]; say @{ +$_ };" abc

    It doesn't even influence context. Not even void!

    >perl -E"sub f { say( ( (wantarray && 'list' ) // 'void' ) || 'scalar' + ); } +f(); $_=+f(); ()=+f();" void scalar list

    What you said is the secondary effect is the only effect.

Re^2: What does a plus mean before a package name?
by anonymized user 468275 (Curate) on May 26, 2011 at 09:49 UTC
    I agree. Given that it isn't some weirder operator like the solitary underscore, it had just better be a unary plus operator and yes, I agree also that brackets are a better idea - sometimes I even think the aura of inconsistency (there is of course a technical distinction) of whether brackets are required by a function or command is a bad thing.

    One world, one people