sub upload_file() { my ($g, $q, $readpath, $writepath) = @_; my ($bytesread, $buffer); if (!open(WFD,"<$readpath")) { $g->errorpage($q, "Could not copy $readpath: $!\n"); return 0; } $| = 1; # turn off buffering of stdout if (!open(WFD,">$writepath")) { $g->errorpage($q, "Error opening file '$writepath' for writing: $!\n"); return 0; } #### ## Error points to the following line #### while ($bytesread = read($readpath,$buffer,1024)) { # can't use string "" as a symbol ref while "strict refs" in use binmode WFD; print WFD $buffer; } close(WFD); $| = 0; # turn on buffering of stdout chmod 0600, "$writepath"; return 1; }