Hi monks

I greatly appreciate all the work developers do in preparing and releasing modules to CPAN - they've enabled me and everyone else here to get stuff done quickly and usually reliably.

But there's one thing in a lot of modules on CPAN that really worries me - too often I see stuff like this (XML::Smart in this case):

my $fh ; open ($fh,">$file") ; binmode($fh) if $unicode ; print $fh $data ; close ($fh) ;
Why do so many authors fail to check for print failures (well ok, open and close failures in this case as well) to files?

I've even written to a couple of authors politely explaining that its useful to know when print is failing because your hard drive is full, but with no success.

I know you can force perl to die on such errors, but I would hope code going into CPAN modules would be doing stuff like:

my $fh ; open ($fh,">$file") or dir "Failed to open: '$file' for write: $!"; binmode($fh) if $unicode ; print $fh $data or die "Failed to write to: '$file': $!"; close ($fh) or warn "Failed to close: '$file': $!";
I work on a lot of data processing scripts, and ignoring a write failure would probably get me the sack - but surely there are relatively few situations where data loss is acceptable?

Can monks suggest anything that can be done to get CPAN modules reviewed and fixed for such problems? I'm prepared to review the odd module or two, but not when I know half the time I'll get ignored by the module author (I'm not suggesting this is the case with XML::Smart BTW, I took this at random as an example!)

If what I'm saying is valid, is there some well known and respected name in the perl community who could write a small article (or I'll write it for them!) for perl.com discussing this - then I can point authors to such an article and they might take notice!

Thanks


In reply to <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.