develooper Front page | perl.perl5.porters | Postings from February 2018

[perl #132866] File::Copy::copy() "works" when given a directory asa from parameter

Thread Previous
James E Keenan via RT
February 14, 2018 14:36
[perl #132866] File::Copy::copy() "works" when given a directory asa from parameter
Message ID:
On Tue, 13 Feb 2018 23:07:40 GMT, wrote:
> This is a bug report for perl from,
> generated with the help of perlbug 1.40 running under perl 5.20.3.
> -----------------------------------------------------------------
> [Please describe your issue here]
> File::Copy::copy() seems to expect that calling
> open $fh, '<', '/dir' or ...
> will fail. However, on HPUX this succeeds and reading from the
> filehandle
> returns a directory listing and some sort of binary data junk.

As far as I can tell from reading "perldoc -f open" and "perldoc perlopentut", what happens when you call "open $fh, '<', 'something'" when 'something' is a directory is pretty much undefined.

Hence, I would expect that when you call "copy $fh", you would get undefined behavior as well.  Moreover, 'perldoc File::Copy' specifically guides you away from attempting to copy from filehandles:

Note that passing in files as handles instead of names may lead to loss of information on some operating systems; it is recommended that you use file names whenever possible.

Thank you very much.
James E Keenan (

via perlbug:  queue: perl5 status: new

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About