From 2683423cd7aae39c7c67a005320f39d6e84a2f1f Mon Sep 17 00:00:00 2001 From: Jim Avera Date: Thu, 22 May 1997 18:10:01 +1200 Subject: Patch to show @INC when require dies When 'require' dies because it can't find the file in @INC, it would be helpful if perl printed out the contents of @INC, to help debu the problem (especially when perl is invoked in devious ways, such as via a C application in which perl is embedded with funny secret -I args passed to perl_parse!). I would like to contribute a patch to 5.004 to do just that. p5p-msgid: 9705230121.AA27872@membrane.hal.com --- pp_ctl.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'pp_ctl.c') diff --git a/pp_ctl.c b/pp_ctl.c index bc3ebb100f..6052cb2d1b 100644 --- a/pp_ctl.c +++ b/pp_ctl.c @@ -2306,10 +2306,20 @@ PP(pp_require) if (!tryrsfp) { if (op->op_type == OP_REQUIRE) { SV *msg = sv_2mortal(newSVpvf("Can't locate %s in @INC", name)); + SV *dirmsgsv = NEWSV(0, 0); + AV *ar = GvAVn(incgv); + I32 i; if (instr(SvPVX(msg), ".h ")) sv_catpv(msg, " (change .h to .ph maybe?)"); if (instr(SvPVX(msg), ".ph ")) sv_catpv(msg, " (did you run h2ph?)"); + sv_catpv(msg, "\n@INC contains:\n "); + for (i = 0; i <= AvFILL(ar); i++) { + char *dir = SvPVx(*av_fetch(ar, i, TRUE), na); + sv_setpvf(dirmsgsv, " %s\n ", dir); + sv_catsv(msg, dirmsgsv); + } + SvREFCNT_dec(dirmsgsv); DIE("%_", msg); } -- cgit v1.2.1