Reputation: 5279
Take this simple test case:
#!/usr/bin/env perl
use Test::Most;
use Scalar::Util qw( reftype );
ok( 1, 'foo' );
done_testing();
Running this test gives me the following output:
Prototype mismatch: sub main::reftype: none vs ($) at /Users/olaf/perl5/perlbrew/perls/perl-5.16.2/lib/site_perl/5.16.2/Exporter.pm line 66.
There are 2 ways I can get rid of this warning.
I'm ok with calling Scalar::Util::reftype (or even using another module), but I'm looking for a little help in debugging this issue so that I can file the appropriate bug report, since I'm not sure as to where the root cause of the warning lies.
Upvotes: 3
Views: 172
Reputation: 118635
Both Test::Most
and Scalar::Util
define functions called reftype
, and the way you are calling use
causes both modules to try to export their reftype
functions to the calling package. Sometimes this will trigger a Subroutine ... redefined
warning, but in this case Scalar::Util::reftype
wants to define itself with a prototype, so the conflict is a more serious error.
Some options other than calling Scalar::Util::reftype($ref)
:
One. to define and use a different alias for Scalar::Util::reftype
use Scalar::Util (); BEGIN { *su_reftype = *Scalar::Util::reftype; } print "reftype is ", su_reftype($ref), " ...";
Two. Remove reftype
from the symbol table before loading Scalar::Util
:
use Test::Most; BEGIN { *{reftype} = '' } use Scalar::Util 'reftype';
Upvotes: 5