Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/perl/10.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 I/O控制操作不当_Perl_Syntax Error - Fatal编程技术网

Perl I/O控制操作不当

Perl I/O控制操作不当,perl,syntax-error,Perl,Syntax Error,我的问题很简单,。但无法解决执行Perl脚本后收到的“不适当的I/O控制操作”错误 #!C:/Perl/bin/perl.exe -w use strict; my $file = "D:/file.csv"; open(my $data, '<', $file) or die "Could not open '$file' $!\n"; while (my $line = <$data>) { chomp $line; my @fields = split

我的问题很简单,。但无法解决执行Perl脚本后收到的“不适当的I/O控制操作”错误

#!C:/Perl/bin/perl.exe -w
use strict;

my $file = "D:/file.csv";
open(my $data, '<', $file) or die "Could not open '$file' $!\n";
while (my $line = <$data>) {
    chomp $line; 
    my @fields = split "," , $line;
    print $fields[1]."\n";
}
#!C:/Perl/bin/Perl.exe-w
严格使用;
my$file=“D:/file.csv”;

打开(我的$数据,我怀疑您的脚本正在通过
打开和死亡$!
打开或死亡$!;打印$!
打印
的值

下面是一个在Windows上复制相同问题的最小脚本:

C:\> perl -e "open my $fh, '<', 'file_that_opens' && die $!"
Inappropriate I/O control operation
在这里,无意义意味着
$!
可能与测试结果无关
open()
运算符


我看不出你的代码有什么明显的错误。你能给我们看完整的错误信息,并告诉我们错误出现在哪一行吗?
D:
?是网络共享吗?“执行后”?执行此脚本的是什么?您确定脚本上说的是
open或die$!;
而不是
open&&die$!
?@taiko:您对ysth的评论与我的回答一致。唯一的
$!
时间意味着失败后立即发生了某些事情,因此在成功的情况下不应考虑通过调试器看到的值l
打开
$ perl -e 'open my $fh, "<", "file_that_opens" && die $!'
Inappropriate ioctl for device
if (open my $fh, "<", $filename) {
              # Here $! is meaningless.
    ...
}
else {        # ONLY here is $! meaningful.
    ...       # Already here $! might be meaningless.
}
# Since here we might have either success or failure,
# $! is meaningless.