Mail::Sender allows you to log all conversation with the SMTP server into a file that will look somewhat like this:

>> 220 ooa Microsoft ESMTP MAIL Service, Version: 5.0.2195.5329 ready +at Wed, 21 May 2003 14:11:18 -0600 << ehlo CZXXPRA01SV0007 >> 250-ooa Hello [xx.xx.xx.xx] >> 250-AUTH GSSAPI NTLM LOGIN >> 250-AUTH=LOGIN ... >> 250 OK << mail from: <jenda@krynicky.cz> >> 250 2.1.0 jenda@krynicky.cz....Sender OK << rcpt to: <jenda@krynicky.cz> >> 550 5.7.1 Unable to relay for jenda@krynicky.cz
This is implemented by replacing the $sender->{socket} with a tied filehandle that reads or writes from/to the original socket and dumps everything read/written into a log file/another filehandle. Which means that the rest of the module doesn't have to care whether the debuging is on or off.

Currently the code implementing this resides within Mail/Sender.pm (package Mail::Sender::DBIO) and only supports print(), readline()/<>, CLOSE() and opened(). Do you think it would be worth to move it to a separate module and add support for other filehandle methods?

If so how should I name the module? And what other filehandle methods should it support?

Update: I guess I did not express this clearly :-) I'm not asking whether it would be more efficient to put the code into a separate file or something. I'm asking whether it would be worth to give the code a life (and name) of its own. Whether it would be worth to unattach the code from Mail::Sender, make it more general and let others use it in their modules.

Jenda
Always code as if the guy who ends up maintaining your code will be a violent psychopath who knows where you live.
   -- Rick Osborne


In reply to Should I extract Mail::Sender's debuging into a separate module? by Jenda

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.