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

The following demonstrates a problem I've come across with the use of the Perl debugger and the warn builtin. I have tried to isolate the problem to as little Perl code as possible. Anyone have a clue how I might get more info from Perl on what's going on?

Thanks,

Harry DeLano

hdelano@adelphia.net

[delano@blackbox test]$ cat junk1 digraph "db-a12" { size="6,2.75"; page="8.5,11"; margin="1"; [delano@blackbox test]$ cat warnproblem.pl open I , "junk1"; @b = <I>; close I; @c[0] = "\tmargin=\"1\";\n"; warn "entering xxx\n"; xxx( @c); $c[0] = $b[3]; warn "entering xxx\n"; xxx( @c); exit; sub xxx { warn "hi.\n"; return; } [delano@blackbox test]$ perl -d warnproblem.pl Loading DB routines from perl5db.pl version 1.19 Editor support available. Enter h or `h h' for help, or `man perldebug' for more help. main::(warnproblem.pl:1): open I , "junk1"; DB<1> c entering xxx hi. main::xxx('\x{9}margin="1";\x{a}') called at warnproblem.pl line 6 entering xxx panic: malloc. Debugged program terminated. Use q to quit or R to restart, use O inhibit_exit to avoid stopping after program termination, h q, h R or h O to get additional info. DB<1> q

Replies are listed 'Best First'.
Re: debugger and warn strangeness
by halley (Prior) on Feb 25, 2004 at 17:35 UTC
    I think you want to phrase your first assignment as a scalar, not a slice. That is, change the @c[0] to $c[0].
    $c[0] = "\tmargin=\"1\";\n";
    This really shouldn't have any effect one way or the other on the operation, since you never declare the @c array anywhere, but maybe the debugger's getting confused.

    It's generally safer to use strict so that you develop the habit of declaring variables and arrays, rather than letting them auto-vivify magically.

    The panic happens in the *second* call to xxx, on the second execution of the same warn line. Does this happen without the debugger? Does this happen with other ways of initializing @b? What version of Perl, and what operating system? I'm guessing Linux from your prompt.

    --
    [ e d @ h a l l e y . c c ]