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
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.