in reply to File Upload - Strict Ref Issue
sub upload_file { my ($g, $q, $readpath, $writepath) = @_; my $rfh; if (!open($rfh, "<", $readpath)) { $g->errorpage($q, "Could not open file '$readpath': $!\n"); return 0; } my $wfh; if (!open($wfh, '>', $writepath)) { $g->errorpage($q, "Error creating file '$writepath': $!\n"); return 0; } binmode($rfh); binmode($wfh); while (read($rfh, my $buf, 4*1024)) { print $wfh $buf; } close($wfh); chmod 0600, $writepath; return 1; }
I got rid of your $| manipulation since you don't even use STDOUT.
I got rid of the sub's prototype. Not only should prototypes be avoided in general, it was completely wrong forcing you to bypass it elsewhere by wrongly adding "&" to sub calls.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: File Upload - Strict Ref Issue
by Heffstar (Acolyte) on Oct 29, 2009 at 15:11 UTC | |
by ikegami (Patriarch) on Oct 29, 2009 at 16:59 UTC | |
by Heffstar (Acolyte) on Oct 29, 2009 at 17:21 UTC | |
|
Re^2: File Upload - Strict Ref Issue
by Heffstar (Acolyte) on Nov 10, 2009 at 18:50 UTC | |
by ikegami (Patriarch) on Nov 10, 2009 at 19:23 UTC |