%INC only contains a mapping from a module name like 'strict.pm' to its full path (Eg. '/usr/share/perl/5.6.1/strict.pm'). Perl uses it in requires and uses to ensure that you can only load a module once. Therefore clearing %INC will only reset perl's idea of what has been loaded and not actually remove any module code from memory.

Removing a module from memory can be as simple as undefing its symbol table like (UPDATE: but only if this actually worked)

undef %strict::;
Although when using Safe you need to do various things to find the right root namespace and delete the module inside of it. You can find out more about the way that perl exposes its package symbol tables to the outside world in perlmod.

After reading this you should understand the code below that lists all the variables in a given namespace.

sub symbols { my $pkg = $_[0] || ''; no strict 'refs'; print "Symbols: ", join(" ", sort keys %{$pkg.'::'}), "\n"; } symbols('strict');

This routine and others are featured in the 'Displaying symbol tables for debugging' snippit.

--
integral, resident of freenode's #perl

In reply to Re: Safe.pm and memory problems by integral
in thread Safe.pm and memory problems by shushu

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.