in reply to Initial Devel::UncheckedOps, a macro for perl

Just a quick question for you diotalevi. What is the reasoning behind altering every print or printf statement and not just those associated with a filehandle other than STDOUT? This question popped into my head when I saw:

print "Hello world!\n"; # Becomes # print "Hello world!\n" or die $!;

I have an idea as to why you did that. Rather than show ignorance and spout off some possibly totally stupid idea (I am still a novice perlguts/B spelunker after all), I think I'll just wait for a response. :)

Replies are listed 'Best First'.
Re^2: Initial Devel::UncheckedOps, a macro for perl
by diotalevi (Canon) on Jun 17, 2004 at 18:02 UTC
    perl -e 'print "'ello world\n" or die $!' > file_on_fs_that_is_already_full

    I still wonder if that would error if the buffer weren't flushed though. It at least makes it more likely especially as the default also puts an `or die $!` on the close() op. There isn't anything to be done about implicit closes though.


    An update. It has been suggested that I patch perl so that failures during implicit closes throw warnings, probably in the 'io' class.

      I did not even think of that one. I was thinking that if someone used select to set the default filehandle then you might need to make a second pass through to figure out what filehandle is really being used.
        What does it matter which filehandle is being written to if an error is throw? I don't follow why you care whether the handle is named STDIN or is default.