Bod wrote:

But, over dinner, whilst tucking into roast pork and sprouts (one of my favourite vegetables), I pondered how to approach this if it was a module I intended to publish on CPAN. This module will never be published, but I can imagine plenty of reasons for CPAN modules to need to write files just for their own use.

Is there a standard way to handle this?
Can we be sure that the module will have write permissions on the directory where it resides?
Is there an environment variable common to all environments for a temporary directory that can be used for this sort of thing?

Despite that fact that I hate and loath sprouts, I am going to reply ;-)

By the time I post this reply you will undoubtedly have received several good suggestions, Bod. What I wanted to add is that there is a standard for such things. It goes by the term XDG Base Directory Specification - cited already by ysth in Re^3: Where to save module data. All flavors of Linux (probably) adhere to it, and the perl module File::HomeDir employs it, as well providing for equivalents in the Windows world.

The specification linked to above will answer several of your questions. Note that, with File::Homedir, only two of the methods provided will actually create directories for you (given the appropriate args). The other methods return undef if the cited directory does not already exist.

Oct 18, 2024 at 19:37 UTC
The open palm of desire
Wants everything, it wants everything
It wants soil as soft as summer
And the strength to push like spring
Paul Simon -> Further to Fly

In reply to Re: Where to save module data by Intrepid
in thread Where to save module data by Bod

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.