Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
binmode clobbers $@ under certain circumstances #10800
Created by email@example.com
This is a bug report for perl from firstname.lastname@example.org,
binmode() can clobber $@ under certain circumstances. This reproduces it:
$@ = 'foo';
open(my $fh, '>/tmp/foo');
Note that setting the binmode to ':raw' does not clobber $@.
If this turns out to not be a bug for some reason, the perldoc for binmode
In case you are curious, the first symptom I saw was die() being unusually
Any place that you call into arbitrarily complex code can clobber $@,
In Perl 5.13 we have made a change so that a DESTROY method clobbering $@
In any case, for a DESTROY method to clobber $@ or other status variables
local($., $@, $!, $^E, $?);
This will avoid your problem on the Perl that you are using, and avoid
On 2010-11-05 22:59, muir @ arubanetworks . com wrote:
No bug. A quality of global variables is, well ... that they are global.
Decent Perl pattern:
To preserve $@ you can localize it in your DESTROY.
See also Try::Tiny and friends.
On Sat, Nov 6, 2010 at 8:03 AM, Zefram <email@example.com> wrote:
That's true, but it's not immediately obvious to a non-expert how
(Though I agree with other comments that it's best practice to
On Sat, 06 Nov 2010, David Golden wrote:
It is also not obvious to non-experts how arbitrarily complex even the
I would like to register _some_ protest against adding gratuitous cruft
On Sat, Nov 6, 2010 at 10:29 PM, Jan Dubois <firstname.lastname@example.org> wrote:
Yes, but tying and overloading is usually done by the user, whereas a
I understand the sentiment, entirely. I still hope someday for