Once I have loaded a file using require, is there a clean way to reload the file?

I am running analyses on several 'families' of text files (Hazard reports, requirements documents, FMEAs.)

A Perl program analyzes the text-files. The program has many options, which I store in a HoH called %runSwitches. Each text-file needs a slightly different set of options.

Each document family has a default set of options, which must be tweaked for the particular text file.

Here's how I set it up: Each document has a short configuration file – documentName.pl. Each family has a file with a set of defaults – family_defaults.pl. The short configuration file loads the defaults, then asserts the tweeks:

require "family_default.pl"; # default values into %runSwitch +es %runSwitches = (%runSwitches, # tweeks for a single document switch1 => 'tweek1', switch2 => 'tweek2');
This works fine. Except now I have a script that iterates though all the documents in a family. The first doc called loads the defaults and runs fine. The second file executes require "family_default.pl"; and does nothing, because family_default.pl is already in %INC. So the tweaks from the first file are still in effect, and I lose. I could Both of these seem like awkward hacks. Is there a better way to do this?

In reply to Right way to force the reloading of a file by throop

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.