in reply to Ideal way to pass a file to a module

Personally, I'd leave the error handling associate with the locating and opening the file to the calling module. The caller has greater knowledge of the application and can better decide how that error handling should be treated. For example, it will be able to couch error messages in terms that the users of the application will better understand.

The application writer (caller) also knows best about where to obtain the file handle; what are appropriate defaults; extensions, locations, open shared, locked, exclusive etc.

So, I would probably pass an open file handle to the module. The module writer knows best how to deal with the data it is expecting; read line-by-line; or fixed length records; or tab delimited etc.

Since 5.8.0, if it makes sense to use a big string for the data, then you can always use a "memory file handle".


Examine what is said, not who speaks.
"Efficiency is intelligent laziness." -David Dunham
"Think for yourself!" - Abigail
  • Comment on Re: Ideal way to pass a file to a module