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

Re: Changing the Perl error message when a module is not found

Thread Previous | Thread Next
Nicholas Clark
September 17, 2012 04:02
Re: Changing the Perl error message when a module is not found
Message ID:
On Mon, Sep 17, 2012 at 12:39:49PM +0200, Michael Stapelberg wrote:

> To address your actual worries about regressions:
> 1. We could make this error message only appear for modern code which
>    includes "use v5.18" (or whenever this might be included).
> 2. We could check if the error message is about to be printed to a TTY
>    (that is, interactively) and only modify it in that case.

Right now, implementation wise, certainly the latter isn't going to fly
(in any clean way). Exceptions are converted to strings at the point they
are generated, and then passed around as strings. At the point the exception
is thrown, the code has no idea where the exception is going to be reported.
No idea if it's trapped, or ultimately going to end up on a terminal.

Also, as is the problem with trying to do something similar for Unicode:

    perl foo                        # outputs to a terminal
    perl foo 2>&1 | someprog        # outputs to a pipe
    perl foo 2>&1 | someprog >log   # outputs to a pipe

As far as the perl binary can work out, the first one is a terminal, the
other two are pipes. As far as the user is concerned, the first *two* are
to the terminal, only the last one is to a file.

I don't think that the former is going to work very well either.

    use v5.18;
    use Foo;

Any error from Foo failing to load Bar will still report old style, because
the effects of use v5.18 are confined to the lexical scope is in.

Nicholas Clark

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