emilford has asked for the wisdom of the Perl Monks concerning the following question:

Hello Monks,

I wrote a simple script for a friend that he will be using to update his CS group's information webpage. His knowledge of Perl is limited, and although I still have MUCH to learn, I can usually produce good enough code to obtain the desired effect.

The script that I wrote does only 2 things:
  1. uploads a pdf file to a specified directory
  2. updates a static html page w/ a link to the uploaded file
The problem is that I was running the script on my current remote server and shortly after received an email from tech support saying that my script "ran wild" and "hogged all of the system resources". I wrote debugging messages (print "Some sort of message\n" if ($DEBUG);) that don't make it seem that the script is doing anything abnormal. The debugging messages are displayed just as I expect them to be and just before the code exit(0); another debugging message is displayed. I'd assume that if it makes it to the debugging message, that it is also going to exit without errors correctly.

Anyway, my real question is how I should go about figuring out what the problem is. I've looked over my code and still do not see anything to abnormal, but tech support claims otherwise. I can only run the script on my remote server and don't have access to the command line. Any help is appreciated!

Replies are listed 'Best First'.
Re: debugging woes
by dragonchild (Archbishop) on Jan 22, 2003 at 15:17 UTC
    Are you sure that tech support knows what they're talking about? Perl can take a lot of system resources, but it frees them up quite quickly (if what you wrote conforms to your requirements list).

    One issue might be if you're reading the PDF into memory before uploading it and the PDF is large. *shrugs* Without than seeing your script and knowing the system, it's hard to help with this kind of debugging. I'm shooting in the dark, really.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

Re: debugging woes
by perrin (Chancellor) on Jan 22, 2003 at 17:50 UTC
    Get details. Is it using too much RAM or too much CPU? Look at the access log and try to reproduce the problem with the requests you see there.
Re: debugging woes
by Cody Pendant (Prior) on Jan 22, 2003 at 22:34 UTC
    What does your code do specifically when it uploads. The correct behaviour for an uploading script is something like:
    while (there's more file to upload){ grab a reasonable chunk of the file, 1Kb for instance write it to the server }

    So if it doesn't do that, it might use a lot of memory, as dragonchild says.
    --
    “Every bit of code is either naturally related to the problem at hand, or else it's an accidental side effect of the fact that you happened to solve the problem using a digital computer.” M-J D
Re: debugging woes
by emilford (Friar) on Jan 23, 2003 at 18:46 UTC
    I haven't had time to look over my code again, but I did get in touch with my tech support. They said the problem was excessive CPU cycles caused by an infinite loop. I'll look over the code soon and hopefully the error will stare me right in the face.