Beefy Boxes and Bandwidth Generously Provided by pair Networks
We don't bite newbies here... much
 
PerlMonks  

Re^2: Choosing namespace/name for (my first) CPAN module which is a sub-class of a well-known distribution

by Anonymous Monk
on Nov 04, 2024 at 23:18 UTC ( [id://11162572]=note: print w/replies, xml ) Need Help??


in reply to Re: Choosing namespace/name for (my first) CPAN module which is a sub-class of a well-known distribution
in thread Choosing namespace/name for (my first) CPAN module which is a sub-class of a well-known distribution

Another question (hopefully they aren't regarded "do the research for me" or "write code for me"). W.r.t. output, is adding a dependency on File::Copy for trivial task a bad idea? Is "append mode" considered undesirable perhaps in file systems I have no experience with?

Originally, a file is always slurped in, content scalar either appended to or re-generated from scratch for incremental or clean save respectively; then output file is opened in create mode and scalar is printed.

In worst case (minute incremental update to a very large file using the same file name), almost exact huge copy is written anew. I don't like this design and re-wrote this part. Incrementally updating to the same file name opens a file in append mode, then as large or small as required data is written. Incrementally updating to a different file name uses File::Copy::copy() before that. Especially useful if original file wasn't slurped-in.

I could do without File::Copy, performing instead read/print loop through some small buffer (16 KB or what's OK value these days), but why shouldn't I use dedicated/optimised module? Only not to add a dependency? On core module?

As to "no appending" in original CAM::PDF, I can envision a case when file is modified by someone between my read and write. Then corrupt PDF would be saved. But it's no worse than my erasing "someone"'s work by opening a file in create mode. Both scenarios are somewhat improbable for PDFs on disk.

  • Comment on Re^2: Choosing namespace/name for (my first) CPAN module which is a sub-class of a well-known distribution
  • Select or Download Code

Replies are listed 'Best First'.
Re^3: Choosing namespace/name for (my first) CPAN module which is a sub-class of a well-known distribution
by sleet (Scribe) on Nov 05, 2024 at 01:26 UTC
    is adding a dependency on File::Copy for trivial task a bad idea?
    Note that it's included in core:
    $ corelist File::Copy Data for 2024-10-20 File::Copy was first released with perl 5.002

      It's worth specifying all dependencies. Some systems ship with a bastardised 'perl', excluding things from the core.

        Agreed. I should have mentioned that. Even though something is in core, it should always be listed in the Makefile.PL (or whatever file your build system uses) as a requirement or dependency.

      is adding a dependency on File::Copy for trivial task a bad idea?

      What sleet is saying here is that it's absolutely not a bad idea to add the dependency to your chain, particularly because it's already in core. Personally, I have quite a few distributions on the CPAN that I wanted to make small, but when it comes to core modules, I'm all in on including them and decreasing my work-load for known-good functionality.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11162572]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others learning in the Monastery: (3)
As of 2025-01-24 17:39 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Which URL do you most often use to access this site?












    Results (68 votes). Check out past polls.