in reply to uploading images into cgi's
I will mention that you shouldn't read the binary file like it is a text file. You definitely should set binmode on the filehandle, otherwise you will run into problems if you ever run the program on a machine with different line endings.
You also shouldn't read the binary file by lines. Either slurp the whole file into a scalar in if you know they won't be too large.
my $data = do { local $/ = undef; <$image_fh>; };
Or read and write the file by blocks:
while (read($image_fh, $buffer, 4096)) { print $buffer; }
|
|---|