On Sun, Oct 12, 2003 at 11:06:49PM -0000, stefan@puce.campus.luth.se (via RT) wrote: > This is a bug report for perl from stefan@puce.campus.luth.se, > generated with the help of perlbug 1.34 running under perl v5.8.1. > > <CODE> > print 'Called from '. (join ' : ', caller ). ' at line '. __LINE__." \$!: $!.\n"; > > my $schack = <RSnaps>; > chomp $schack; > print "In Snaps1:\$!: $!. gameStatus: $gameStatus, Schack: $schack\n"; > <\CODE> > > <OUTPUT> > Called from Net::Telnet : /usr/local/lib/perl5/site_perl/5.8.1/Net/Telnet.pm : 2123 at line 103 $!: Interrupted system call. > In Snaps1:$!: Bad file descriptor. gameStatus: 3, Schack: oGame over > <\OUTPUT> > > The code is called from a caught $SIG{USR1} not realy from Telnet.pm but the > script is usually waiting in a Telnet::getline() when the signal arrives. > > This did not happen in 5.8.0 but it does with 5.8.1. Sorry for the late reply to this bug report. I believe you are slightly misunderstand how $! should be used. $! refers to the error status from the last OS system call that *failed*. If a later call succeeds, $! still holds to the old error message, eg: print "err1: $!\n"; open F, "/nosuchfile"; print "err2: $!\n"; open F, "/etc/passwd"; print "err3: $!\n"; outputs: err1: err2: No such file or directory err3: No such file or directory You should only examine the content of $! when you know an error has occured; usually by the perl function returning undef, eg open F, "/nosuchfile" or print "err: $!\n"; A single perl function such as 'open' can sometimes make several OS system calls, not all which may succeed, but for which the overall result is regarded as being successul; eg 'use Foo' may fail to open several files before finding the file in @INC. Hope this helps, Dave. -- A major Starfleet emergency breaks out near the Enterprise, but fortunately some other ships in the area are able to deal with it to everyone's satisfaction. -- Things That Never Happen in "Star Trek" #13Thread Previous