I don't know if this is wise, but I'd like to be able to set global default variables for a package at build time. The perl module is a back end designed to communicate with a JavaScript front end (see https://github.com/zachhh/Packform). The global variables are for things like the path (as in the href attribute of a script tag, not strictly the path on disk) for including the front end JS, the desired version of jQuery and the jQuery UI, etc.

This is entirely out of laziness -- I don't want to have to provide this information in every script using the module. The defaults are hardcoded to be suitable for the server on which it was built. I want to be able to specify these when I install it.

This would necessarily have to change the variable initializations in the .pm file (which seems dangerous -- but hey, make test will tell them something's wrong if they mess it up). Of course, this could also come from a configuration file or the like. But, that seems dirty too.

Is this approach unwise?

If this is a reasonable approach, what are the recommendations? Should this be done in Makefile.PL somehow? Should there be a conf file that is provided and ask the user to modify that if they want changes? How should that be incorporated?


In reply to Configure global default variables in package at install time by zachhh

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.