autoconf-patches
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Autom4te::General


From: Russ Allbery
Subject: Re: Autom4te::General
Date: Mon, 02 Jun 2003 12:36:13 -0700
User-agent: Gnus/5.090008 (Oort Gnus v0.08) XEmacs/21.4 (Portable Code, sparc-sun-solaris2.6)

Alexandre Duret-Lutz <address@hidden> writes:
>>>> "Russ" == Russ Allbery <address@hidden> writes:

>  Russ> That's also what die does, if the message ends in a newline.

> I'm not talking about the formating, but about die's handling of $!.
> Die is clearly designed to be called immediately after an error from a
> function which updated $!.  Any other attempt to use die _must_ be
> protected with `$! = 0;', or `die' might reuse an obsolete $! value from
> a former error (it's even worse: I think the recent WEXITSTATUS issue
> was caused by Perl's autoloading of WEXITSTATUS failing to preserve $!).

I'm sorry, I don't understand.  If you end the die message with a newline,
it doesn't do anything with $! at all.

The standard Perl programming idiom looks like this:

    open (FILE, $file) or die "cannot open $file: $!\n";

If you don't want to include $! because it's not relevant, don't include
it in the argument to die.

You can, if you choose, leave off the newline at the end of die, at which
point Perl tries a wide variety of magic to figure out some reasonable
error message for you, but this is more akin to an internal exception.
It's not the way to generate user error messages, since it includes
various internal bits about the implementation that the user generally
doesn't care about.

-- 
Russ Allbery (address@hidden)             <http://www.eyrie.org/~eagle/>




reply via email to

[Prev in Thread] Current Thread [Next in Thread]