good chemistry is complicated,
and a little bit messy -LW
Sub calling sadnessby nefigah (Monk)
|on Mar 08, 2008 at 06:26 UTC||Need Help??|
nefigah has asked for the
wisdom of the Perl Monks concerning the following question:
I've seen warnings in the docs/on PM/in books about how to call functions, and it finally bit me in a weird way.
Oddly, I recall someone saying that user-defined functions SHOULDN'T be called using & (and if you do use it, to make sure you use parentheses).
That sounded good to me, so I was avoiding using & and (), when I ran into this sort of scenario (in my unit test file):
(Names changed to protect the innocent.)
So I get an error at the blah2 test, (like, not the test failing, but a compile error) and was very confused.
Well, putting parentheses thusly fixed it:
ok( ThatPackage::blah($bar), 'blah2' );
Which is fine and dandy, but makes me somewhat sad because I don't understand why that's necessary just because the stupid string in $bar has leading whitespace. :(
I don't suppose some kind monk could make sense of it for me?
I'm a peripheral visionary... I can see into the future, but just way off to the side.