我有一個模塊Routines.pm:爲什麼我的Perl程序會抱怨需要顯式包名?
package Routines;
use strict;
use Exporter;
sub load_shortest_path_matrices {
my %predecessor_matrix = shift;
my %shortestpath_matrix = shift;
...
}
從另一個腳本我所說的子模塊中,通過在其中恰好有相同的名稱參數:
use Routines;
use strict;
my %predecessor_matrix =();
my %shortestpath_matrix =();
&Routines::load_shortest_path_matrices($predecessor_matrix, $shortestpath_matrix);
然而,這不編譯,我得到
全局符號「$ predecessor_matrix」需要明確的包名
類型的錯誤。在Perl中不可能像這樣在不同的範圍中給變量賦予相同的名稱? (我來自C背景)
鄒所知,Perl是比C不同,儘管在關鍵字誤導性相似之處。我的建議是去購買和閱讀「學習Perl」來學習Perl「認爲」的方式。 – lexu 2009-09-20 17:17:19
「使用診斷」;將有助於 – 2009-09-21 11:35:15