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

[PATCH] Unwanted warnings from PerlIO::scalar

Thread Next
Ben Morrow
January 30, 2008 07:20
[PATCH] Unwanted warnings from PerlIO::scalar
Message ID:
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.


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