develooper Front page | perl.perl5.porters | Postings from September 2012

Changing the Perl error message when a module is not found

Thread Next
From:
Michael Stapelberg
Date:
September 16, 2012 12:07
Subject:
Changing the Perl error message when a module is not found
Message ID:
x6obl5dbwq.fsf@midna.zekjur.net
Hey,

I’ve been dealing with people who have little to no experience with
Perl over several years. A very common problem for people who are new to
Perl is to figure out why a Perl script does not work when it spits
something in their face along the lines of

    Can't locate LWP/UserAgent.pm in @INC (@INC contains: /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4 /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12 /usr/local/lib/site_perl .) at -e line 1. 
    BEGIN failed--compilation aborted at -e line 1.

Therefore, as a first step to help people with it, I’ve created
http://michael.stapelberg.de/cpan/ where I can point people to when they
encounter this problem and ask for help.

However, it’d be much better to make Perl itself say something more
helpful in that situation (many people don’t even ask for support and
just give up).

Therefore, what do you think about changing the Perl error message when
modules are not found to something like this?

    ERROR: Could not load Perl module LWP::UserAgent

    I looked for LWP/UserAgent.pm in these paths (@INC):
    /etc/perl /usr/local/lib/perl/5.12.4 /usr/local/share/perl/5.12.4
    /usr/lib/perl5 /usr/share/perl5 /usr/lib/perl/5.12 /usr/share/perl/5.12
    /usr/local/lib/site_perl

    Try installing LWP::UserAgent, for example with cpan -i
    LWP::UserAgent

Key is that the last message (which people look at first) is helpful and
the right solution for this problem. Also, the rest of the error message
talks about LWP::UserAgent (not LWP/UserAgent.pm) and clearly explains
that this is a Perl module (giving the user a keyword to search for and
a better understanding of the problem).

Please CC me in your replies.
Thanks,
Best regards,
Michael

Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About