Update: I wrote the below, obviously after reading
ikegami's answer above. Yet, I went on, totally wrong. The only problem with his answer was that it's a bit terse. When the sub you are calling eats the rest of the argument list, you get surprises. For example, look at
print. It seems a litle silly that
ok() is OK with only one argument, but it is, which hides the real problem in your code.
sorry for confusing... (e.g.:disregard the rest of this post)
It is not possible to explain the semantics of your code without access to the definition of ThatPackage. If you could include that definition, we could probably better explain what happens and why.
For example, include your definition of ThatPackage::blah something like this (after verifying that it still demonstrates the problem):
use Test::More 'no_plan';
#require 'some_file_with_my_functions.pm';
package ThatPackage;
sub blah { return $_[0] =~ /hi/ }; # Does NOT demonstrate the problem
package main;
my $foo = "hi";
my $bar = " hi";
ok( ThatPackage::blah $foo, 'blah' );
ok( ThatPackage::blah $bar, 'blah2' );
ok( ThatPackage::blah($foo), 'blah3' );
ok( ThatPackage::blah($bar), 'blah4' );
cheers
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.