Beefy Boxes and Bandwidth Generously Provided by pair Networks
Your skill will accomplish
what the force of many cannot

Re^12: file upload and IO::Handle

by rowdog (Curate)
on Sep 10, 2010 at 20:44 UTC ( #859694=note: print w/replies, xml ) Need Help??

in reply to Re^11: file upload and IO::Handle
in thread file upload and IO::Handle

No, I don't really know why and it's honestly a lot of code to wade through. The main reason that you don't know is because you never check to see if things succeed or fail. Here's what I mean, in your hook sub, you have this code.

open (SES, ">$_sloc/$sessid.session"); print SES "$bytes_read:$length:$percent"; close (SES);

From my point of view, that's an error, what happens if you can't open the file? You just blindly write to it anyhow and the whole script ought to fail right there. As I said before, ALWAYS CHECK THE RETURN FROM OPEN. The simple fix is

open (SES, ">$_sloc/$sessid.session") or die $!; print SES "$bytes_read:$length:$percent"; close (SES);

Then try it and see if anything shows up in the server logs. After that, start the debugging process... use warn statements to ensure your variables contain what they ought to. Stick a warn @_; as the first line of the hook subroutine to be sure it's getting called and check that the parameters are sane. Then comment out the warn lines when it's working right.

Replies are listed 'Best First'.
Re^13: file upload and IO::Handle
by Anonymous Monk on Sep 11, 2010 at 02:12 UTC
    It might be simpler to add
    use autodie;
    at the top of the script, better error messages at least
      Only error was in the ping, it could not open the file as it did not exist.

      No errors from hook, as if it is not even executing.
      Very strange in deed!

      Any other ideas?

        Ok, I even had the intital ping wait 5 seconds to make sure hook had time to write something to the file if it executed, still nothing.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://859694]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others pondering the Monastery: (5)
As of 2020-09-24 09:52 GMT
Find Nodes?
    Voting Booth?
    If at first I donít succeed, I Ö

    Results (132 votes). Check out past polls.