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

Hi,

is there any module available to produce a similar output as Carp::ret_backtrace() of Carp 1.01?

We have to use Perl 5.6.1 at this customer because that's included with Red Hat 7.3 and this customer would loose Linux support if he'd install something else he says....

TIA


Update: Carp 1.01 is in Perl's core since 5.8, the older version (without version numer) included in 5.6.1 does not have such a nice ret_backtrace()...


Search, Ask, Know

Replies are listed 'Best First'.
Re: Alternative to Carp::ret_backtrace?
by batkins (Chaplain) on Nov 05, 2003 at 11:39 UTC
    Carp will definitely work with Perl 5.6. You don't have to install it, but whoever is threatening to take away your customer's Linux support really needs to wise up - most Perl scripts will need some kind of module installed at some time or another and it's pretty childish to make blanket policies like that.

    But this shouldn't be a problem because Carp is included in the core Perl distribution. So just use Carp; and you should be fine.

    Are you sure it was a book? Are you sure it wasn't.....nothing?
      Sorry, I thought it was clear:

      The problem is that Carp is a core-only module, so we cannot update Carp to v1.01 without updating the whole Perl installation...

      Installing modules is not a problem, or to be more exact, is just the problem of the poor guy who has to make rpms from the CPAN tgzs ;-))


      Search, Ask, Know
        Ah, OK. The problem still isn't insurmountable. Just get the Carp distribution off CPAN. Then copy Carp.pm into the same directory as your script, make a Carp directory (also in the same directory as your script), and then copy Carp/Heavy.pm into the Carp folder.
        Are you sure it was a book? Are you sure it wasn't.....nothing?
        The problem is that Carp is a core-only module, so we cannot update Carp to v1.01 without updating the whole Perl installation...

        That's simply not true -- read perlmodinstall

Re: Alternative to Carp::ret_backtrace?
by Joost (Canon) on Nov 05, 2003 at 15:49 UTC
    Either install the Carp and Carp::Heavy modules from perl 5.8 under some local library, or write your own version: I used something like:

    my $i; while (1) { my ($pack,$file,$number,$sub) = caller($i) or last; printf "%02d| \&$sub called at $file line $number\n",$i++; }
    Joost
    -- #!/usr/bin/perl -w use strict;$;= ";Jtunsitr pa;ngo;t1h\$e;r. )p.e(r;ls ;h;a;c.k^e;rs ";$_=$;;do{$..=chop}while(chop);$_=$;;eval$.;
Re: Alternative to Carp::ret_backtrace?
by tilly (Archbishop) on Nov 07, 2003 at 07:33 UTC
    Warning, Carp was rewritten from scratch in Perl 5.6 and Perl 5.8. It could easily be rewritten again in Perl 5.10. If so, then undocumented internal functions like ret_backtrace() would be unlikely to be maintained.

    I strongly recommend that you write your own version of that (which isn't hard using caller). Furthermore the advice to not go liberally borrowing undocumented internals is basic good programming advice that applies to any modules that you aren't maintaining.