Plus, the docs for $! state "after a failure". There is no definition for "failure" given, but I assume it means after readline returns undef, which it does on both EOF and I/O error. Therefore, it is valid to check the value of $! in the case under consideration, since readline has returned undef.
Could you please post the output of "uname -a" on the version of unix where you ran my test program and the version of perl you used to run it? Here are my results for a variety of perl versions and unices, plus Windows XP. The only version that displays the strange behavior of modifying $! on EOF is Windows XP.
AIX 5.2 This is perl, version 5.005_03 built for aix n=5 s=I/O error n=6 s=No such device or address n=0 s= This is perl, v5.8.0 built for aix-thread-multi n=5 s=I/O error n=6 s=No such device or address n=0 s= AIX 5.3 This is perl, v5.8.2 built for aix-thread-multi n=5 s=I/O error n=6 s=No such device or address n=0 s= SunOS 5.8 This is perl, version 5.005_03 built for sun4-solaris n=5 s=I/O error n=6 s=No such device or address n=0 s= This is perl, v5.6.0 built for sun4-solaris n=5 s=I/O error n=6 s=No such device or address n=0 s= SunOS 5.9 This is perl, version 5.005_03 built for sun4-solaris n=5 s=I/O error n=6 s=No such device or address n=0 s= This is perl, v5.6.0 built for sun4-solaris n=5 s=I/O error n=6 s=No such device or address n=0 s= This is perl, v5.6.1 built for sun4-solaris-64int n=5 s=I/O error n=6 s=No such device or address n=0 s= Linux 2.4.2-2 This is perl, v5.6.0 built for i386-linux n=5 s=Input/output error n=6 s=No such device or address n=0 s= Linux 2.4.21-47.0.1.ELsmp This is perl, v5.8.0 built for i386-linux-thread-multi n=5 s=Input/output error n=6 s=No such device or address n=0 s= CYGWIN_NT-5.1 1.5.19(0.150/4/2) This is perl, v5.8.7 built for cygwin-thread-multi-64int n=5 s=Input/Output error n=6 s=No such device or address n=0 s= Windows XP This is perl, v5.8.7 built for MSWin32-x86-multi-thread n=0 s= n=0 s= n=0 s=
In reply to Re^8: Best way to handle readline errors?
by jrw
in thread Best way to handle readline errors?
by jrw
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |