develooper Front page | perl.perl5.porters | Postings from March 2016

wording of perldiag's implicit close warning text

Thread Next
From:
Dave Mitchell
Date:
March 23, 2016 16:15
Subject:
wording of perldiag's implicit close warning text
Message ID:
20160323161447.GV29332@iabyn.com
last year I added an entry to the 5.22.0 perldelta that described the new

    Warning: unable to close filehandle %s properly: %s

warning in more detail. I propose that that text gets added to the (rather
spartan) existing entry in perldiag:


-------


 =item Warning: unable to close filehandle %s properly: %s
 
-(S io) An error occurred when Perl implicitly closed a filehandle.  This
-usually indicates your file system ran out of disk space.
+(S io) Prior to version 5.22.0, perl silently ignored any errors when
+doing an implicit close of a filehandle, I<i.e.> where the reference count
+of the filehandle reached zero and the user's code hadn't already called
+<close(); for example,
+
+    {
+        open my $fh, '>', $file  or die "open: '$file': $!\n";
+        print $fh $data or die "print: $!";
+    } # implicit close here
+
+Due to buffering, in a situation such as disk full the error may only be
+detected during the final close, so not checking the result of the close
+is dangerous.
+
+So perl now warns in such situations.




-- 
The Enterprise is involved in a bizarre time-warp experience which is in
some way unconnected with the Late 20th Century.
    -- Things That Never Happen in "Star Trek" #14

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