我在Perl中有一個共享模塊。主程序需要兩個文件,第一個是共享文件(我們稱它爲'X'),第二個爲'包'文件。文件'X'也包含在使用'require'的'包'文件中。當我編譯這個程序,它給了我以下錯誤:Perl問題「需要」相同的文件
Undefined subroutine &main::trim called at testing.pl line 8.
我的理解是,perl找不到trim()模塊。如果我不包含軟件包文件,那麼這將運行沒有任何問題。
任何人都可以解釋這個問題?
這是我的代碼:
主程序:testing.pl
#!/usr/bin/perl -w
use strict;
use postgres;
require "shared.pl";
trim("als");
包文件:postgres.pm
#!/usr/bin/perl
package postgres;
use strict;
use DBI;
require "shared.pl";
1;
共享文件:shared.pl
#!/usr/bin/perl
# =============
# shared module
# =============
use strict;
sub trim($)
{
}
1;
'delete $ INC {「shared.pl」};'waaaa?拿去! – ikegami