Beefy Boxes and Bandwidth Generously Provided by pair Networks DiBona
Just another Perl shrine
 
PerlMonks  

Re: Should Modules Do I/O?

by duct_tape (Hermit)
on Mar 18, 2005 at 11:33 UTC ( [id://440735]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Should Modules Do I/O?

I personally do not see a problem with the module doing the i/o as long as it does proper error handling. Having an interface that it easy to use will make it more useful to people.

One idea is that you routines could expect different parameters depending on how the user wants to handle the i/o. For example someone could pass you in a string with the file name if they don't care if you do the i/o. Or they could pass in existing filehandles if they want to handle it themself.

And finally one other thing that could be done is to have the method(s) return the data, but then also provide methods that will deal with reading and writing the data as well. That way they are not forced to use your i/o handling, but instead can add an extra line or two of code to use it.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://440735]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.