Perl. caller, , . .
Most often, I want to see the stack trace during debugging. Good news, it's easy to get a stack trace, just use Carp confess and cluckinstead of dieand warn.
use strict;
use warnings;
use Carp;
bar(6.1);
bar(1);
sub foo {
confess "Oh noes" unless @_ == 6;
}
sub bar {
my $count = shift;
cluck "bar is in trouble" unless int $count == $count;
foo( ('a')x $count );
}
This will help you:
dao:~ toad$ perl test.pl
bar is in trouble at test.pl line 14
main::bar(6.1) called at test.pl line 5
Oh noes at test.pl line 9
main::foo('a') called at test.pl line 15
main::bar(1) called at test.pl line 6
source
share