Randal L. Schwartz wrote:

DSam> If you're on Linux (or Solaris IIRC) you could always use:
DSam>   my $num_fh = $#{[</proc/$$/fd/*>]}+1;
Not even sure that's the same thing.  If 0, 1, 2, 11, and 15 are open,
does that return 3?  Or 5?  Is it finding the first free fd, or one
more than the count of open fds?


Just the open file descriptors - in your example it would be 5. One is just added because it's $#, not scalar @{}


themachine:/proc/9894/fd$ cd /proc/$$/fd
themachine:/proc/9894/fd$ perl -le 'print $#{[</proc/$$/fd/*>]}+1;'
5
themachine:/proc/9894/fd$ ls
0  1  2  255  4
themachine:/proc/9894/fd$




Reply via email to