develooper Front page | perl.perl5.porters | Postings from October 2003

Re: new slurp module

Thread Previous | Thread Next
From:
Uri Guttman
Date:
October 23, 2003 10:44
Subject:
Re: new slurp module
Message ID:
x7ptgndf2s.fsf@mail.sysarch.com
>>>>> "GA" == Gisle Aas <gisle@ActiveState.com> writes:

  GA> Ilya Martynov <ilya@iponweb.net> writes:
  >> I've seen file::slurp reinvented zillion times even if developers knew
  >> about it (along "it is so simple module and I don't want another
  >> external dependancy" line of reasoning).  There must be a core module
  >> for this!  Both thumbs up for including it in core. And, yeah, I'd
  >> keep old name.

  GA> I agree.  I think File::Slurp is a fine name for this but I don't like
  GA> the current API.  The function names to read/write whole files need to
  GA> be short and sweet, otherwise why bother.  I always reinvent the
  GA> reader as a function called cat() myself but I'm not sure I would
  GA> recommend that name.

i can add other aliases such as slurp and spew (in @EXPORT_OK)

  GA> Other issues with such an API:
  GA>    - binmode or not by default

there is a binmode option on both read_file/write_file

  GA>    - how to specify IO layers to use

pass it in the binmode option as it is passed to binmode directly so you
can set a discipline.

  GA>    - how to report errors

rtfm. it can return undef or carp or croak

  GA>    - should it write directly or write to a temp and then rename

the write_file overwrites existing files

  GA> The reader is probably much more useful than the writer and it is
  GA> simpler to agree on how it should work.  I would consider only having
  GA> that.

i agree that read_file would be called much more often than
write_file. but i would think having both in the core would be not a
problem. the code is very short and the whole module is also small.

  GA> The current append_file() and overwrite_file() functions seems useless
  GA> to me.  If you want this you are probably better off using open and
  GA> friends.

those are aliases or wrappers that are only for backwards compatibility
with the current File::Slurp on cpan. neither are needed as their
behavior is supported in write_file. this breaking of that compatibility
is one reason i was interested in a new namespace. but the consensus so
far is to keep it file::slurp as that is already familiar.
is 

uri

-- 
Uri Guttman  ------  uri@stemsystems.com  -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs  ----------------------------  http://jobs.perl.org

Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About