Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/file/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
无法在perl CGI中打印文件内容_Perl_File_Cgi_File Handling - Fatal编程技术网

无法在perl CGI中打印文件内容

无法在perl CGI中打印文件内容,perl,file,cgi,file-handling,Perl,File,Cgi,File Handling,我想在网页中逐行打印文件的内容 这是我拒绝工作的代码 open(CNF, '<G:\automation_managment\".$n."\config.txt') or die "cant open"; my @cnf=<CNF>; close(CNF); my $i= 0; print "your city, $cnf[$i]"; $i++; print "your age, $cnf[$i]"; $i++; print "your grade, $cnf[$i]";

我想在网页中逐行打印文件的内容 这是我拒绝工作的代码

open(CNF, '<G:\automation_managment\".$n."\config.txt') or die "cant open";
my @cnf=<CNF>;
close(CNF);
my $i= 0;
print "your city, $cnf[$i]"; 
$i++;
print "your age, $cnf[$i]"; 
$i++;
print "your grade, $cnf[$i]"; 
$i++;
print "your phone number, $cnf[$i]"; 
$i++;
print "your email id, $cnf[$i]";
open(CNF),更改此行:

open(CNF, '<G:\automation_managment\".$n."\config.txt') or die "cant open";

open(CNF,'既然你在做'或死',你应该最清楚可能出现的错误。提示:你应该使用'或死'不能打开:$!';获取错误消息。由于使用单引号,$n没有计算。问题是$n没有计算,即使我使用了双引号,也无法获取死亡消息。我不确定您是否共享了完整的代码:您在哪里设置了$n,可能还有“使用警告”和“使用严格”给你们一些更多的提示。若并没有这样的运气,它会在test.pl第28行,靠近“'I'd suggest sprintf”的地方打印反斜杠(“我投反对票的原因是open的2 arg版本和糟糕的错误消息。是的,这是可行的,但这不是我希望人们在使用搜索引擎找到答案时看到的建议。@innaM:我刚刚用OP的代码更正了它。我还提出了一个3 arg open的解决方案。”。
open(CNF, '<G:\automation_managment\'.$n.'\config.txt') or die "cant open";
open(my $fh, '<', 'G:/automation_managment/'.$n.'/config.txt') or die "cant open"