0

在以下 perl 脚本中,

#!/usr/local/bin/perl
use Env;
use strict;
use warnings;
my $oscar_file = "input/oscar_single_piminus_1k.input";
my $PISAEvent_file  = "output/PISAEvent_piminus_1k.root";
my %pisa_input = "pisa_piminus_1k.input" ;
my %pisa_start = "pisa < pisa_piminus_1k.input";
my $nevents = 1000;
open(INPUT, ">" . $pisa_input);
print INPUT "0\nN\n0\n";
close(INPUT);
open(INPUT2,">glogon.kmac");
print INPUT2 "macro glogon.kumac\npisafile $PISAEvent_file\ntext_file $oscar_file -1 1\nptrig $nevents\nexit\nreturn\n";
close(INPUT2);
my $ret = system($pisa_start);

它返回以下错误,

Global symbol "$pisa_input" requires explicit package name at pisa.pl line 26.
Global symbol "$pisa_start" requires explicit package name at pisa.pl line 32.
Execution of pisa.pl aborted due to compilation errors.

注释掉“使用严格”没有帮助,

Name "main::pisa_input" used only once: possible typo at pisa.pl line 26.
Name "main::pisa_start" used only once: possible typo at pisa.pl line 32.
Odd number of elements in hash assignment at pisa.pl line 15.
Odd number of elements in hash assignment at pisa.pl line 20.
Use of uninitialized value in concatenation (.) or string at pisa.pl line 26.
print() on closed filehandle INPUT at pisa.pl line 27.
Use of uninitialized value in system at pisa.pl line 32.

到底是怎么回事?

4

2 回答 2

5

my %pisa_start = "pisa < pisa_piminus_1k.input";

my $ret = system($pisa_start);

%$

这些是您使用的两条彼此不一致的行。如果您觉得它仍然没有问题,请阅读您最喜欢的关于变量的 Perl 教程。

于 2012-05-29T20:31:18.260 回答
3

您没有$pisa_input在任何地方声明,并且您使用的是名为相同 ( %pisa_input) 的哈希图。

你可能的意思是:

my $pisa_input = "pisa_piminus_1k.input" ;
my $pisa_start = "pisa < pisa_piminus_1k.input";
于 2012-05-29T20:33:31.253 回答