Printing to a file handle with insufficient disk space does not produce a failure, at least not on my system. Rather, the failure happens when you call close(). A lot of people don't check the return value of close() (including me), but maybe they should.

To test this, I created a 1 MB loopback filesystem and wrote a bit of Perl to write a lot of data to it:

$ dd if=/dev/zero of=./test_small_lo count=1 bs=1M 1+0 records in 1+0 records out $ sudo /sbin/losetup /dev/loop0 ./test_small_lo $ sudo /sbin/mkfs.ext2 /dev/loop0 [ snip output ] $ sudo mount /dev/loop0 /mnt/data $ df Filesystem 1K-blocks Used Available Use% Mounted on /dev/loop0 1003 13 939 2% /mnt/data [ snip other mounted file systems ] $ cd /mnt/data $ sudo touch test_file $ sudo chmod 666 test_file # So I don't have to run code below as root $ perl -e ' > open( FH, ">", "test_file" ) or die $!; > for( 0 .. 10_000_000 ) { print FH 1 or die $! } > close(FH) or die $! ' No space left on device at -e line 3.

I honestly don't see the point in checking print()'s return value. It puts in more code that will only happen for such extremely rare occasions that you can simply discount them.

Update: See my reply to adrianh below.

----
send money to your kernel via the boot loader.. This and more wisdom available from Markov Hardburn.


In reply to Re: <rant>CPAN modules failing to check for write errors</rant> by hardburn
in thread <rant>CPAN modules failing to check for write errors</rant> by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.