From: Robert Spier Date: Wed, 19 Dec 2001 14:13:38 +0000 (-0800) Subject: Carp.pm caller_info returns wrong info for eval X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=976ea96eb039ee807127647136ce79d22e3b465f;p=p5sagit%2Fp5-mst-13.2.git Carp.pm caller_info returns wrong info for eval Message-ID: <15393.4370.605214.548582@rls.cx> p4raw-id: //depot/perl@13816 --- diff --git a/lib/Carp.t b/lib/Carp.t index a318c19..e9dd8cd 100644 --- a/lib/Carp.t +++ b/lib/Carp.t @@ -5,7 +5,7 @@ BEGIN { use Carp qw(carp cluck croak confess); -print "1..7\n"; +print "1..8\n"; print "ok 1\n"; @@ -51,3 +51,8 @@ sub_6; print "ok 7\n"; +# test for caller_info API +my $eval = "use Carp::Heavy; return Carp::caller_info(0);"; +my %info = eval($eval); +print "not " if ($info{sub_name} ne "eval '$eval'"); +print "ok 8\n"; diff --git a/lib/Carp/Heavy.pm b/lib/Carp/Heavy.pm index 5228b9b..5de3972 100644 --- a/lib/Carp/Heavy.pm +++ b/lib/Carp/Heavy.pm @@ -77,14 +77,14 @@ sub get_status { # the sub/require/eval sub get_subname { my $info = shift; - if (defined($info->{eval})) { - my $eval = $info->{eval}; + if (defined($info->{evaltext})) { + my $eval = $info->{evaltext}; if ($info->{is_require}) { return "require $eval"; } else { $eval =~ s/([\\\'])/\\$1/g; - return str_len_trim($eval, $MaxEvalLen); + return "eval '" . str_len_trim($eval, $MaxEvalLen) . "'"; } }