<?xml version="1.0" encoding="windows-1252"?>
<node id="1003647" title="Prototypes being ignored with use_ok() from Test:More ?" created="2012-11-13 11:08:50" updated="2012-11-13 11:08:50">
<type id="115">
perlquestion</type>
<author id="1003638">
JPMH</author>
<data>
<field name="doctext">
I've got some weirdness I don't understand when I load a module with Test::More's use_ok()

&lt;p&gt;I was using an array-reference prototype to pass an array by reference without the module user having to fuss about it -- but when I load the module with Test::More's use_ok()
all the prototypes seem to be getting ignored.&lt;/p&gt;

&lt;p&gt;What is it I'm missing ?&lt;/p&gt;

&lt;p&gt;Here's a cut-down example module, CST2.pm:&lt;/p&gt;

&lt;code&gt;
package CST2;
use strict;
use warnings;
use Exporter; 
our @ISA = qw(Exporter); 
our @EXPORT = qw(ArrayCount); 


sub ArrayCount(\@) {
	(my $array_Ref, undef) = @_;
	my $ct;
	foreach my $element (@{$array_Ref}) {
		$ct++
	}
	$ct;
}

1;
&lt;/code&gt; 

and a calling script,

&lt;code&gt;
#!/usr/bin/perl
use strict;
use warnings;
use Test::More;

#BEGIN:{ use_ok('CST2'); }

use CST2;

my @patternList = qw(one two three);
my $count = ArrayCount(@patternList);
print "$count\n";
&lt;/code&gt;

&lt;p&gt;With &lt;code&gt;use CST2&lt;/code&gt; everything works fine.&lt;/p&gt;

&lt;p&gt;But if I change to &lt;code&gt;BEGIN:{ use_ok('CST2'); }&lt;/code&gt;, then I get an error:
'Can't use string ("one") as an ARRAY ref while "strict refs" in use at CST2.pm line 12.'&lt;/p&gt;

&lt;p&gt;To make the error go away, I have to change the call in the script to explicitly pass a reference
&lt;code&gt;my $count = ArrayCount(\@patternList);&lt;/code&gt;&lt;/p&gt;

&lt;p&gt;Why is this happening?  What is it I've missed, and should have done differently?&lt;/p&gt;

&lt;p&gt;For what it's worth, &lt;code&gt;perl --version&lt;/code&gt; tells me I'm running perl 5, version 14, subversion 2 (v5.14.2) built for cygwin-thread-multi-64int (with 7 registered patches, see perl -V for more detail); and it's version 0.98 of Test::More&lt;/p&gt;

&lt;p&gt;Thanks in advance,&lt;/p&gt;
 
&lt;p&gt;JH.&lt;/p&gt;
</field>
</data>
</node>
