Perl I/O控制操作不当
我的问题很简单,。但无法解决执行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
#!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.