A piggy bank of commands, fixes, succinct reviews, some mini articles and technical opinions from a (mostly) Perl developer.

Jump to

Quick reference

A unary-plus sign before a package name in Perl

ok +Some::Package::Foo->a_method_call($var), 'test succeeded';

This is to get around Perl's 'indirect object syntax'.
Otherwise
ok Mock::Basic->update(...);
looks like
Mock::Basic->ok->update(...);
which is probably not what is intended.
ok(Mock::Basic->update(...)); works as well.

It tells the parser "Hi. Since I have a leading (unary) plus sign, I'm now a scalar expression, so I qualify to match the first item in ok()'s prototype; please do not get confused and interpret me as a class name you should call an ok() method on."

Demonstration:
perl -MCGI -MTest::More -e'ok 1, "ok"; ok +CGI->new, +CGI->new; ok scalar CGI->new, "scalar"; ok( CGI->new, "brackets" ); ok CGI->new, "no plus";'
ok 1 - ok
ok 2 - CGI=HASH(0x8b68c0)
ok 3 - scalar
ok 4 - brackets
Undefined subroutine CGI::ok
 at -e line 1

See alsoand