[TroubleShooting]Inappropriate I/O control operation

There's more than one way to do it!
https://metacpan.org http://perlmonks.org
回复
头像
523066680
Administrator
Administrator
帖子: 573
注册时间: 2016年07月19日 12:14
联系:

[TroubleShooting]Inappropriate I/O control operation

帖子 523066680 »

触发条件:
open my $WRT, ">:utf8", "b.txt" or die "$!";
print $!;
close $WRT;
Inappropriate I/O control operation

my question is rather simple,. but can't resolve "Inappropriate I/O control operation" error which I'm receiving after execution of my Perl script.
#!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";
}
any idea, what I'm doing wrong? I'm running this script on ActiveState perl on windows7

===========================================================================

This behavior is documented

According to perldoc perlvar, $! is only meaningful in the event of a failure. When open is called, it sets a value for $!, but the value is only useful if the open did not succeed:

... $! is meaningful only immediately after a failure:
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.
Here, meaningless means that $! may be unrelated to the outcome of the open() operator.
回复

在线用户

正浏览此版面之用户: 没有注册用户 和 1 访客