in reply to CGI Error

Change, in the line 50, OUTPUT by STDOUT.

Update: Misread question.

It seems that $fh is not defined when you use it in open OUTPUT $buffer, check it. The code below reproduces the error:

use Fcntl qw(:DEFAULT :flock); sysopen(OUTPUT, "output.bin", O_CREAT|O_EXCL|O_WRONLY) or die $!; binmode OUTPUT; while (read(my $fh, my $buffer, 4096)) { print OUTPUT $buffer; } close OUTPUT or die $!;


Igor S. Lopes - izut
surrender to perl. your code, your rules.

Replies are listed 'Best First'.
Re^2: CGI Error
by izut (Chaplain) on Sep 27, 2005 at 12:39 UTC

    Also there are an error in this code: my $fh = $q->upload( $file ); It should be like this (according to CGI.pm): my $fh = $q->upload( 'my_upload_field_from_form' );

    From CGI.pm:

    To be safe, use the upload() function (new in version 2.47). When called with the name of an upload field, upload() returns a filehandle, or undef if the parameter is not a valid filehandle.
    $fh = upload("uploaded_file"); while (<$fh>) { print; }


    Igor S. Lopes - izut
    surrender to perl. your code, your rules.