I included an exit method so that I could easily log a message and exit with a specified error code and the same time. In an early project with this module, I found that I was regularly logging some message and then croaking with the same message. This made for an ugly mess and much duplicated code. To fix this, I added the exit method.

While I can see your point about automatically opening the file, something about it bothers me. I could make it possible to control open and close in a call to the constructor. But, since I chose not to use named parameters in the method calls, at that puts a real constraint on how many parameters each method can take without becoming cumbersome. I'd have to add two parameters to new. I hate functions and methods with long parameter lists, so I have say I can't agree to this one. I also feel like there is a built-in expectation that you have to open a file to use it. This module is intended to be a rather thin wrapper around a file handle. Of course it would be a simple matter to subclass and add this feature if one desired it.

Your points about auto-opening the handle and what it means to be simple really do emphasize brian_d_foy's point about good naming.

Your point about closing on a DESTROY is well taken. I've mostly used this on windows systems, which don't choke up if you fail to close a filehandle. But it could be used on other systems that might have that failing. I really should add a DESTROY method.


TGI says moo


In reply to Re: [OT] Re: Module Renaming Suggestions by TGI
in thread Module Renaming Suggestions by TGI

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.