加入收藏 | 设为首页 | 会员中心 | 我要投稿 李大同 (https://www.lidatong.com.cn/)- 科技、建站、经验、云计算、5G、大数据,站长网!
当前位置: 首页 > 大数据 > 正文

perl – 不适当的I / O控制操作

发布时间:2020-12-16 06:17:54 所属栏目:大数据 来源:网络整理
导读:我的问题很简单.但无法解决执行我的Perl脚本后收到的“不适当的I / O控制操作”错误. #!C:/Perl/bin/perl.exe -wuse strict;my $file = "D:/file.csv";open(my $data,'',$file) or die "Could not open '$file' $!n";while (my $line = $data) { chomp $lin
我的问题很简单.但无法解决执行我的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";
}

任何想法,我做错了什么?我在Windows7上的ActiveState perl上运行此脚本

解决方法

我怀疑你的脚本是打印$的值!通过一个开放的&&死!或开放或死亡$!;打印$!;.

这是一个在Windows上重现相同问题的最小脚本:

C:&; perl -e "open my $fh,'file_that_opens' && die $!"
Inappropriate I/O control operation

以下是* nix上发生的事情:

$perl -e 'open my $fh,"<","file_that_opens" && die $!'
Inappropriate ioctl for device

记录此行为

根据perldoc perlvar,$!只有在失败的情况下才有意义.调用open时,它会为$!设置一个值,但该值仅在open未成功时才有用:

$! is meaningful only immediately after a failure:

06002

Here,meaningless means that $! may be unrelated to the outcome of
the open() operator.

(编辑:李大同)

【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容!

    推荐文章
      热点阅读