diff options
author | Jim Avera <avera@hal.com> | 1997-05-22 18:10:01 +1200 |
---|---|---|
committer | Tim Bunce <Tim.Bunce@ig.co.uk> | 1997-06-11 12:00:00 +1200 |
commit | 2683423cd7aae39c7c67a005320f39d6e84a2f1f (patch) | |
tree | 98a9b78045cd664beba4983ef857a1a84e9ac0d4 /pp_ctl.c | |
parent | 66b1d5575fd5eb6242bac2e9a08b163be8b1b960 (diff) | |
download | perl-2683423cd7aae39c7c67a005320f39d6e84a2f1f.tar.gz |
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
Diffstat (limited to 'pp_ctl.c')
-rw-r--r-- | pp_ctl.c | 10 |
1 files changed, 10 insertions, 0 deletions
@@ -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); } |