我
知道
我想做的这类事情过去常常在5.8中工作。我做错什么了吗?有没有办法回到Perl5.10中?
模块如下:
package TableMod;
use base qw<Exporter>;
our @EXPORT_OK = qw<mod_table>;
use Data::Dumper;
sub mod_table (\%@) { print Dumper( @_ ); }
1;
下面是剧本:
use strict;
use warnings;
use Data::Dumper;
use Test::More tests => 4;
sub mod_table_here (\%@) {
print Dumper( @_ );
}
use_ok( 'TableMod', 'mod_table' );
can_ok( __PACKAGE__, 'mod_table' );
is( prototype( \&mod_table_here ), '\\%@'
, q/prototype( \&mod_table_here ) = '\%@'/
);
is( prototype( \&mod_table ), prototype( \&mod_table_here )
, 'prototypes ARE the SAME!'
);
my %table = qw<One 1>;
mod_table_here %table => ( 1, 2, 3, 4 );
#mod_table %table => ( 1, 2, 3, 4 );
mod_table( %table, 1, 2, 3, 4 );
我要做的就是取消对最后一行的注释,我得到:
Useless use of modulus (%) in void context at - line 17.
Useless use of a constant in void context at - line 17.
Useless use of a constant in void context at - line 17.
Useless use of a constant in void context at - line 17.
Bareword "mod_table" not allowed while "strict subs" in use at - line 17.
它不抱怨当地的潜艇,但对进口潜艇失去了信心。除此之外,尽管测试告诉我我已经导入了“mod_table”,但strict现在被混淆了,它是一个空词!
不仅如此,尽管测试告诉我原型是相同的,我
不能
通过
%table
作为对导入子的hashref。即使我使用常规语法,也不会,如最后一行所示。
我得到的是:
1..4
ok 1 - use TableMod;
ok 2 - main->can('mod_table')
ok 3 - prototype( \&mod_table_here ) = '\%@'
ok 4 - prototypes ARE the SAME!
$VAR1 = {
'One' => '1'
};
$VAR2 = 1;
$VAR3 = 2;
$VAR4 = 3;
$VAR5 = 4;
$VAR1 = 'One';
$VAR2 = '1';
$VAR3 = 1;
$VAR4 = 2;
$VAR5 = 3;
$VAR6 = 4;