in reply to Debugging DBD::Chart

Look at your installation of DBD::Chart::Plot, and skip to line 3626. That may give you some idea what is happening.

A random guess might be that it is trying to figure out some parameter from an environment variable, and a different environment running from cron causes the division by 0 error. That would explain why you get a different result when running from cron. You can control for that by using RE (tilly) 3: Get default login environment to be sure that you get the same environment running from cron and by hand.

Another idea might be to create an edited version of DBD::Chart that inserts a Carp::cluck right before the warning. Examine the messages emitted. The stack backtrace on the last one before you die tells you which call to print_graph gave a division by 0, which is at least somewhere to start.

FWIW it looks like the warning caused by DBD::Graph is a red herring for your problem (though it should be reported to the author).

UPDATE: Random style tips.

I should point out that there is research indicating that a consistent indent in the 2-4 character range improves comprehension over larger indent.

Also you used a C-style for-loop (for (my $i=0; $i<$max_wedges; $i++) { ... }). The most common coding error in C is an off-by-one error, and if you use them liberally in Perl, you will also have off-by-one errors. Being in the habit of using ranges will avoid those. Though admittedly in this case. for my $i (0..($max_wedges - 1)) { ... } involves more thought about the boundary condition than the C-style loop did.

UPDATE 2: Cunningly hide the fact that I misread the error message by fixing which module I said to examine. Stupidly ruin the effect by confessing to everything.

Replies are listed 'Best First'.
Re: Re: Debugging DBD::Chart
by fuzzyping (Chaplain) on Feb 21, 2004 at 04:15 UTC
    First, there is no line 3626. That's the first thing I looked for, and found that Chart.pm contains only 3253 lines. Figure that one out.

    As far as the red herring, I don't have any other problem. I'm simply trying to determine why I'm seeing these errors, and only via cron.

    Update: Damn, I read that module path wrong. I was checking Chart.pm instead of Plot.pm.

    -fp
      It looks like you figured out how Chart.pm can only have 3253 lines. :-) The misreading was mine originally. :-(

      And on the red herring, I guessed that. I'm just reassuring you that the warning just says that someone else in a different situation could have a problem. Which isn't the problem that you are having. So you can safely put it out of your mind while trying to debug this.