... hence your CB comment - with which I wholeheartedly agree :D
I've seen code such as your 2nd example fail if there's no __DATA__ section in the file.
As to the 1st example, well that's a different kettle of fish...
Given a simple script (tst.pl):
>cat tst.pl
use warnings;
use strict;
use Fcntl qw/:flock/;
open SELF, "< $0" or die ;
flock SELF, LOCK_EX | LOCK_NB or die "$!";
A simple run results in...
>perl tst.pl
A file descriptor does not refer to an open file. at tst.pl line 7.
Re-ruuning and generating a truss log, using >truss -f perl tst.pl > log 2>&1, the (business) end of which is...
.
.
.
389372: open("tst.pl", O_RDONLY|O_LARGEFILE) = 3
389372: kioctl(3, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
389372: fstatx(3, 0x30020848, 128, 010) = 0
389372: kfcntl(3, F_SETFD, 0x00000001) = 0
389372: kfcntl(3, F_SETLK, 0x2FF222A0) Err#9 EBADF
389372: access("/usr/lib/nls/msg/en_GB/libc.cat", 0) Err#2 ENOENT
389372: access("/usr/lib/nls/msg/en_US/libc.cat", 0) = 0
389372: _getpid() = 389372
389372: open("/usr/lib/nls/msg/en_US/libc.cat", O_RDONLY) = 4
389372: kioctl(4, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
389372: kfcntl(4, F_SETFD, 0x00000001) = 0
389372: kioctl(4, 22528, 0x00000000, 0x00000000) Err#25 ENOTTY
389372: kread(4, "\0\001 �\007\007 I S O 8".., 4096) = 4096
389372: lseek(4, 0, 1) = 4096
389372: lseek(4, 0, 1) = 4096
389372: lseek(4, 0, 1) = 4096
389372: _getpid() = 389372
389372: lseek(4, 0, 1) = 4096
389372: close(4) = 0
A file descriptor does not refer to an open file. at tst.pl line 7.
389372: kwrite(2, " A f i l e d e s c r".., 68) = 68
389372: kfcntl(2, F_GETFL, 0x00000008) = 1
389372: kfcntl(1, F_GETFL, 0x00000008) = 1
389372: kfcntl(2, F_GETFL, 0x00000008) = 1
389372: close(3) = 0
389372: kfcntl(2, F_GETFL, 0x00000008) = 1
We see, from 389372: open("tst.pl", O_RDONLY|O_LARGEFILE) = 3 that the script is successfully opened on file descriptor 3.
Later, we see that the file on descriptor 3 is both open, the operations are valid and the file will/should close across an exec call...
389372: fstatx(3, 0x30020848, 128, 010) = 0
389372: kfcntl(3, F_SETFD, 0x00000001) = 0
From 389372: kfcntl(3, F_SETLK, 0x2FF222A0) Err#9 EBADF, we can see that the kernel considers FD3 to refer to a closed file - but we haven't seen a close - either explicitly (via a call to close()) or implicitly (via an intervening call to exec()).
Thus we can only conclude that there is an underlying problem with AIX.
As to a suitable answer ... I'm afraid I can't help you (aside from the fact that there is, in perl 5.8, nothing untoward mentioned in perlaix - but I expect you already know that! :-) :-((
A user level that continues to overstate my experience :-))
|