You might not want to suggest to others to use that bit of code. Slurping an entire uploaded file into a scalar is a Bad Thing(Anyone know of a trademark on this? {grin}). What if I want to upload a 10MB file? You're going to have to hold 10MB in memory. Bad. Instead, you should be using something like this, dealing with one line at a time:
my $file = $cgi->param('datei');
my $fh = $cgi->upload('datei');
while (my $text = <$fh>) {
# Do something... like this maybe:
print $out_file $text;
}
You might even want to consider looking at read() to read in a specific number of bytes on each pass through the loop. I generally don't go as far as to do that though. So what if my binary uploads might slurp a little more if there's a large chunk of fle with no newlines in it? :) (P.S: I won't even pretend to know how frequently newlines appear in a binary file. All I know is that they are there.)
If the above content is missing any vital points or you feel that any of the information is misleading, incorrect or irrelevant, please feel free to downvote the post. At the same time, reply to this node or /msg me to tell me what is wrong with the post, so that I may update the node to the best of my ability. If you do not inform me as to why the post deserved a downvote, your vote does not have any significance and will be disregarded.
|