Branch: refs/heads/yves/fix_19472_warns_on_undef_scalar_ref_open
  Home:   https://github.com/Perl/perl5
  Commit: 614782ad48a22845a0e4cad632b3dd073c2d60e5
      
https://github.com/Perl/perl5/commit/614782ad48a22845a0e4cad632b3dd073c2d60e5
  Author: Yves Orton <[email protected]>
  Date:   2022-03-03 (Thu, 03 Mar 2022)

  Changed paths:
    M doio.c
    M t/io/open.t

  Log Message:
  -----------
  Fix GH Issue #19472: read warnings from open($fh,">",\(my $x))

We produce all kinds of warnings if someone opens a scalar reference
that is undef. Prior to this we handled write operations ok, at
least in blead, but read operations would produce a plethora of
warnings. To me this analagous to treating an undef var as hash
and trying to read from it, we autovivify the undef var to be
a hash. So in this case we should just "autovivify" the referenced
scalar to be an empty string.

Eg before this patch:

./perl -Ilib -wle'open my $fh,"+>", \(my $v); my @x=<$fh>; print 0+@x'
Use of uninitialized value $fh in <HANDLE> at -e line 1.
Use of uninitialized value $fh in <HANDLE> at -e line 1.
Use of uninitialized value $fh in <HANDLE> at -e line 1.
Use of uninitialized value $fh in <HANDLE> at -e line 1.
Use of uninitialized value $fh in <HANDLE> at -e line 1.
Use of uninitialized value $fh in <HANDLE> at -e line 1.
Use of uninitialized value $fh in <HANDLE> at -e line 1.
0

After it:
./perl -Ilib -wle'open my $fh,"+>", \(my $v); my @x=<$fh>; print 0+@x'
0


Reply via email to