I'd just go with the use vars approach. Your only mistake was not initializing your variables at compile time. This is a very common mistake and is often misdiagnosed.

use base qw( Exporter ); our @EXPORT; BEGIN { @EXPORT= qw( $MC_CONFIG_DBI_DRIVER $MC_CONFIG_DB_NAME $MC_CONFIG_DB_USER $MC_CONFIG_DB_PWD $MC_CONFIG_FILE $MC_CONFIG_FEED_LOGS $MC_CONFIG_ARCHIVE_LOGS ); } use vars @EXPORT;

You see, in your original code, the my @var declares the @var array at compile time but doesn't initialize it (fill it with values) until run time. But use vars happens at compile time so you end up passing use vars an empty array.

The our trick can only half work since the "create lexical alias" part of our only has effect until the end of the current scope. So your map might be able to declare a bunch of package globals for you but the lexical aliases to them would disappear at the end of the enclosing block (either the block in the map statement or the next one -- I'd have to test to say for sure). But to get that to work probably requires eval, which also forces an enclosing block so there is no way to script doing our on a list of variable names unless you want to enclose almost your entire module inside an extra eval.

        - tye (but my friends call me "Tye")

In reply to (tye)Re: How to set a set of our and @EXPORT variables concisely? by tye
in thread How to set a set of our and @EXPORT variables concisely? by princepawn

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.