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

Changing the Perl error message when a module is not found

Thread Next
Michael Stapelberg
September 16, 2012 12:07
Changing the Perl error message when a module is not found
Message ID:

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/ 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 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/ 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

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

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/ 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.
Best regards,

Thread Next Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About