Perl“全局符号" [英] Perl "Global symbol"

查看:42
本文介绍了Perl“全局符号"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在下面的 perl 脚本中,

In the following perl script,

#!/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.

注释掉use strict"没有帮助,

Commenting out "use strict" does not help,

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.

这是怎么回事?

推荐答案

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

my $ret = system($pisa_start);

%$.

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

Those are the two lines you used that are not agreeing with each other. If it still doesn't look wrong to you, go read your favorite Perl tutorial on variables.

这篇关于Perl“全局符号"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆