in reply to Re^2: possible bug in opening file handle to variable
in thread possible bug in opening file handle to variable

It seems to apply only for opening file handles to strings instead of files.

Indeed. I was trying to explain the reason for that in the bit that confused you. Let me try to explain better.

Perl file handles are not the same as OS file handles. The OS file handles are called file descriptors.

Perl file handles are only associated with a file descriptors when there's a real file (or pipe, etc) involved. That's not the case for file handles created using open(FILE, \$var), because the OS didn't create them. Those file handles exist solely within perl, so perl gives them the invalid file descriptor -1. fileno returns the file descriptor associated with a Perl file handle.

open DUP, ">&FILE" is Perl's interface to a function that works on file descriptors, not Perl file handles. open DUP, ">&FILE" is more or less equivalent to the pseudocode DUP.fileno = dup(FILE.fileno); Therefore, it won't work on file handles opened using open(FILE, \$var) because they don't have corresponding file descriptor.