Debugging scripts

It still won't work. What else can I do?

Well, I've heard from some people who've just gone for a re-install: either their IIS installation, or their Perl installation (try fetching the latest Perl from ActiveState, if you use that).

I've heard that having your scripts on a networked drive breaks backticks. News to me, but you might try running your scripts from a drive local to the server.

If you're using ActiveState's dll version, try the exe. If you're using the exe, try the dll. Hey, it might work. :-)

Can you help me..?

I get asked this a lot, and the answer is, probably not. My advice is to read through this FAQ carefully, and think about your problem. I get lots of mail which says, "I've read your FAQ", which usually translates to "Well, I've seen the URL, anyway."

If you mail me, I'll do my best to answer, but only if it looks like you've put enough effort into trying to solve the problem yourself, which generally means that you've narrowed the problem to specifically what works and what doesn't, and when. Chances are, if you manage that, then you'll be beyond my knowledge too, but until then, you'll be being too vague, and you'll be wasting my time as well as yours.

Please note: I've changed jobs. I don't have access to any type of IIS server any more. I'm working from six-month-old memories, and that's as of this writing.

Best advice: buy a good book (such as Lincoln Stein's) on being a web master, read it, and learn the HTTP protocols.

How do I determine what the problem is?

Break it down into smaller pieces; "my script doesn't work" is waaay too vague.
  1. Does your URL get found, or rejected? Check the error message; try other scripts in the same directory, or others.
  2. Does perl get invoked? Try changing the App Mappings, so that perl invokes a fixed script instead of the requested one (and make that fixed script do something you can detect even if it produces no output).
  3. Does perl find and run your script? Put debugging statements right at the start of your script, in BEGIN{ } blocks, that write a useful message to a world-writable file, so you know it's been invoked.
  4. How far does your script run, before it breaks? What is the actual line that causes problems? Put more debugging statements through the script, writing output to a logfile.
  5. Have you got your pathnames right? Remember that backslashes in double-quotes is a bad idea. Lots of perl-ish things aren't happy with drive letters either, so if you can have everything on your C drive, life will probably be easier.
  6. Is perl finding all your libraries? Don't rely on IIS running your script with the script's directory as its current directory, so require and use lib statements should have absolute paths.
  7. Yes, use lib. You might have modules in non-standard directories.
  8. If you're invoking programs and they don't work, try invoking other ones, ones that are simpler, and have different behaviour - determine whether it's perl, the script, or the program that is causing the problem.

Steve Kilbane. Whitecrow home.