develooper Front page | perl.perl5.porters | Postings from January 2008

[PATCH] Unwanted warnings from PerlIO::scalar

Thread Next
From:
Ben Morrow
Date:
January 30, 2008 07:20
Subject:
[PATCH] Unwanted warnings from PerlIO::scalar
Message ID:
20080130141006.GA6782@osiris.mauzo.dyndns.org
This code

    use warnings;

    for (1..2) {
        open my $FH, '<', \my $buffer;
        close $FH;
    }

gives an uninitialized value warning on the second iteration only. The
cause is that $buffer is being reused, so that although it is undef it
is no longer SVt_NULL. The attached patch fixes this. Oddly, $buffer is
not reused (so the warning doesn't occur) if the 'close' line is
omitted: I presume this is just because things are happening slightly
out of order at scope-end ($buffer is recreated for the next iteration
before $FH is implicitly closed) and isn't a real problem?

The patch is against 5.10.0, but should also apply cleanly to blead and
to 5.8, if desired.

Ben


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