I changed the settings.pl to use regular key names instead of variables. If I want to interpret a file as perl code, I generally use an eval this way:
$ cat settings.pl %default_settings = ( verbose => 1, debug => 0, help => 0, game => "etqw" ); $ cat app.pl #!/usr/bin/perl -w my $settings_file = "./settings.pl"; use strict; my %default_settings = (); open SETTINGS,$settings_file or die "cannot open $settings_file"; my @data = <SETTINGS>; eval "@data"; close SETTINGS; my %settings = %default_settings; print $_,'->',$settings{$_},"\n" foreach (keys %settings); $ ./app.pl verbose->1 game->etqw debug->0 help->0
This allows me to not 'require' anything at startup but rather gives me the flexibility to do what I need if I need it.

"The three principal virtues of a programmer are Laziness, Impatience, and Hubris. See the Camel Book for why." -- `man perl`

In reply to Re: Sharing a variable between (>=) 2 files by LighthouseJ
in thread Sharing a variable between (>=) 2 files by dichtfux

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.