in reply to package DB penalty?

The @DB::args array is populated by copying the pointers from the actual @_ array, so the cost is a pretty negligible fraction of a caller() invocation - grep for the reference to PL_dbargs in pp_ctl.c to find the 20-odd line block of code involved (within pp_caller()).

I should stress that this is not intended for everyday use, and would suspect that overly imaginative use of this facility is likely to lead you to coredumps and JAPHs.

Hugo

Replies are listed 'Best First'.
Re: Re: package DB penalty?
by Rhandom (Curate) on May 15, 2003 at 14:31 UTC
    Thank you. This is exactly the type of answer I was looking for.

    I agree with the "not intended for everyday use." Simple assignment of @args = @DB::args or @args = map {Carp::format_arg($_)} @DB::args can cause a blow up. A case we see a lot is when there is a single argument with a value of undef. It happens occasionally - but it does happen. Kind of frustrating when a cluck that is supposed to debug info takes the entire script down. Wish I had an easily duplicatable code snippet for you - but usually there is a bit of a caller trace involved.

    Thanks again.

    my @a=qw(random brilliant braindead); print $a[rand(@a)];