http://qs321.pair.com?node_id=802217

luker has asked for the wisdom of the Perl Monks concerning the following question:

On an old Redhat system with perl 5.6, this was part of the code to read an uploaded file and write to a file in the file system:

while (read($fh, $buffer, 1024)) { print $out_handle $buffer; }

where $fh was simply the name of the uploaded file. I am migrating the code to a Debian box with perl v5.10.0 and the above has stopped working, with:

read() on unopened filehandle

I tried using the CGI::upload method, like this:

my $handle_in = $cgi->upload('file_image');

where file_image is the name of the CGI param. But $handle_in is then undef. (I have checked that $cgi->param('file_image') does return the filename.)

Any help gratefully appreciated.