人们继续给我鲤鱼的例子,而不是警告。为什么?什么使鲤鱼比警告更好?
解决方法
carp给你更多的信息,消息来自哪里(上下文)
#!/usr/bin/perl use Carp; foo(); bar(); baz(); sub foo { warn "foo"; } sub bar { carp "bar"; } sub baz { foo(); bar(); }
产生
foo at ./foo.pl line 9. bar at ./foo.pl line 13 main::bar() called at ./foo.pl line 6 foo at ./foo.pl line 10. bar at ./foo.pl line 14 main::bar() called at ./foo.pl line 19 main::baz() called at ./foo.pl line 7