summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--cpan/parent/t/parent.t4
-rw-r--r--pp_ctl.c30
-rw-r--r--t/op/require_errors.t2
3 files changed, 25 insertions, 11 deletions
diff --git a/cpan/parent/t/parent.t b/cpan/parent/t/parent.t
index 401fe39d5d..6ee4494e8a 100644
--- a/cpan/parent/t/parent.t
+++ b/cpan/parent/t/parent.t
@@ -58,10 +58,10 @@ is( $Eval2::VERSION, '1.02' );
eval q{use parent 'reallyReAlLyNotexists'};
-like( $@, q{/^Can't locate reallyReAlLyNotexists.pm in \@INC \(\@INC contains:/}, 'baseclass that does not exist');
+like( $@, q{/^Can't locate reallyReAlLyNotexists.pm in \@INC \(you may need to install the reallyReAlLyNotexists module\) \(\@INC contains:/}, 'baseclass that does not exist');
eval q{use parent 'reallyReAlLyNotexists'};
-like( $@, q{/^Can't locate reallyReAlLyNotexists.pm in \@INC \(\@INC contains:/}, ' still failing on 2nd load');
+like( $@, q{/^Can't locate reallyReAlLyNotexists.pm in \@INC \(you may need to install the reallyReAlLyNotexists module\) \(\@INC contains:/}, ' still failing on 2nd load');
{
my $warning;
local $SIG{__WARN__} = sub { $warning = shift };
diff --git a/pp_ctl.c b/pp_ctl.c
index 3faa9b0a52..19c2417113 100644
--- a/pp_ctl.c
+++ b/pp_ctl.c
@@ -3932,22 +3932,36 @@ PP(pp_require)
if (namesv) { /* did we lookup @INC? */
AV * const ar = GvAVn(PL_incgv);
I32 i;
+ SV *const msg = newSVpv("", 0);
SV *const inc = newSVpvs_flags("", SVs_TEMP);
for (i = 0; i <= AvFILL(ar); i++) {
sv_catpvs(inc, " ");
sv_catsv(inc, *av_fetch(ar, i, TRUE));
}
+ if (len >= 4 && memEQ(name + len - 3, ".pm", 4)) {
+ const char *c, *e = name + len - 3;
+ sv_catpv(msg, " (you may need to install the ");
+ for (c = name; c < e; c++) {
+ if (*c == '/') {
+ sv_catpvn(msg, "::", 2);
+ }
+ else {
+ sv_catpvn(msg, c, 1);
+ }
+ }
+ sv_catpv(msg, " module)");
+ }
+ else if (len >= 2 && memEQ(name + len - 2, ".h", 3)) {
+ sv_catpv(msg, " (change .h to .ph maybe?) (did you run h2ph?)");
+ }
+ else if (len >= 3 && memEQ(name + len - 3, ".ph", 4)) {
+ sv_catpv(msg, " (did you run h2ph?)");
+ }
/* diag_listed_as: Can't locate %s */
DIE(aTHX_
- "Can't locate %s in @INC%s%s (@INC contains:%" SVf ")",
- name,
- (len >= 2 && memEQ(name + len - 2, ".h", 3)
- ? " (change .h to .ph maybe?) (did you run h2ph?)" : ""),
- (len >= 3 && memEQ(name + len - 3, ".ph", 4)
- ? " (did you run h2ph?)" : ""),
- inc
- );
+ "Can't locate %s in @INC%" SVf " (@INC contains:%" SVf ")",
+ name, msg, inc);
}
}
DIE(aTHX_ "Can't locate %s", name);
diff --git a/t/op/require_errors.t b/t/op/require_errors.t
index 1f243a66b4..c60bc7d1b7 100644
--- a/t/op/require_errors.t
+++ b/t/op/require_errors.t
@@ -27,7 +27,7 @@ for my $file ($nonfile, ' ') {
eval "require $nonfile";
-like $@, qr/^Can't locate $nonfile\.pm in \@INC \(\@INC contains: @INC\) at/,
+like $@, qr/^Can't locate $nonfile\.pm in \@INC \(you may need to install the $nonfile module\) \(\@INC contains: @INC\) at/,
"correct error message for require $nonfile";
eval {