【发布时间】:2009-09-20 16:55:48
【问题描述】:
我有一个模块 Routines.pm:
package Routines;
use strict;
use Exporter;
sub load_shortest_path_matrices {
my %predecessor_matrix = shift;
my %shortestpath_matrix = shift;
...
}
我从另一个脚本调用模块中的 sub,传入恰好具有相同名称的参数:
use Routines;
use strict;
my %predecessor_matrix = ();
my %shortestpath_matrix =();
&Routines::load_shortest_path_matrices($predecessor_matrix, $shortestpath_matrix);
但是,这不能编译,我得到了
全局符号“$predecessor_matrix”需要明确的包名
错误类型。在 Perl 中是否不能为不同范围内的变量赋予相同的名称? (我是C背景的)
【问题讨论】:
-
zou 可以看出 Perl 与 C 不同,尽管在关键字方面存在误导性的相似性。我的建议是去购买并阅读“Learning Perl”以了解 Perl“思考”的方式。
-
"使用诊断;"会有所帮助