in reply to Re^2: guidelines for inline coding
in thread guidelines for inline coding

As rare and weird as it is, print can return false. Can’t remember who but some monk was so concerned about it they advocated checking its return on each call.

Completely pointless. What are you going to do if it returns false? print an error message?


With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

Replies are listed 'Best First'.
Re^4: guidelines for inline coding
by Anonymous Monk on Sep 25, 2014 at 19:46 UTC
    What are you going to do if it returns false?
    use strict; use File::Temp 'tempfile'; my $fh = tempfile(UNLINK=>1); select($fh); print "foo" or warn "print 1 fail"; close $fh; print "bar" or warn "print 2 fail"; __END__ print 2 fail at - line 8.

    ... or I could die, print somewhere else like a log, etc.

    While of course I still wouldn't check every print call in a normal program, I take your post to be implying that there's nothing one can do and any checking of the return value is "Completely pointless".

      And what if warn also fails? Ditto die? Shouldn't you be checking those also?

      Both quite likely if the cause of the print (to stdout) is console corruption or failure; or memory exhaustion; or device failure; or ...


      With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.
        ... if the cause of the print (to stdout) is console ...

        ... which is why the example is of a print that isn't to the console. Remember we're talking about print in general here (Laurent_R's example is also printing to a filehandle $ERRORS).