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 UTCIn reply to Re: Where to save module data
by Intrepid
in thread Where to save module data
by Bod
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |