Leser: 22
1
2
3
4
5
6
7
8
open(IN,"/tmp/file.txt");
my $ret=$!;
print "$ret\n";
if($ret){
print "NOK\n";
} else {
print "OK\n";
}
Quote$ perl open.pl
Inappropriate ioctl for device
NOK
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
$OS_ERROR
$ERRNO
$! If used numerically, yields the current value of the C "errno" variable, or
in other words, if a system or library call fails, it sets this variable.
This means that the value of $! is meaningful only immediately after a
failure:
if (open(FH, $filename)) {
# Here $! is meaningless.
...
} else {
# ONLY here is $! meaningful.
...
# Already here $! might be meaningless.
}
# Since here we might have either success or failure,
# here $! is meaningless.
1 2 3 4 5 6
my $ret = open(IN,"/tmp/file.txt"); if($ret){ print "OK\n"; } else { print "NOK [$!]\n"; }
my $ret = open(IN,"/tmp/file.txt");
2010-10-27T08:33:34 LinuxerSchau doch mal in die erste Antwort von pq... msg #142195
Quotethe value of $! is meaningful only immediately after a failure
2010-10-27T08:31:10 tobyHi Leute,
Hat noch jemand eine Idee, warum das "$!" bei open() unter Linux mit "Inappropriate ioctl for device" gefüllt wird? Die Datei kann doch ohne Probleme geöffnet werden...