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

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".

Replies are listed 'Best First'.
Re^5: guidelines for inline coding
by BrowserUk (Patriarch) on Sep 25, 2014 at 20:56 UTC

    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).

        Even so. If the cause is that there is not enough memory to construct the output string; it doesn't matter where the output is intended to go.

        And if a file device is full, thus preventing the write, it will be patently obvious where the problem lies because the entire system will have fallen in a heap.

        And if the problem is a network connection has gone away; or a pipe has closed; or ...; most OS's will display an appropriate and detail diagnostic on the associated console (if there is one) anyway. A diagnostic that is invariably a better diagnostic than most programmers will provide.

        Let the OS do what it is designed to do.


        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.