This is what I've tried just as a test that everyone can try. The file is editing, I don't think Module::Reload does anything here as doesn't the INC have only to do with modules you reload at startup?
#!/usr/bin/perl use Module::Reload; require "test_mod.pl"; print "File Contents (1):\n"; read_file(); print "the control:\n"; test_pl(); undefSub('test_pl'); write_file("test_mod.pl","#!/usr/bin/perl\n\nsub test_pl {\n print \"z +ippy doo\";\n}\n\n\$hello=2;"); print "\n\n\n\n"; print "File Contents (2):\n"; read_file(); print "\n\n\n\n"; require "test_mod.pl"; Module::Reload->check; print "the test:\n"; test_pl(); print "\n\n\n\n"; write_file("test_mod.pl","#!/usr/bin/perl\n\nsub test_pl {\n print \"b +ack to normal\";\n}\n\n\$hello=1;"); sub read_file { open( FILE, "< test_mod.pl" ) or die "Can't open test_mod.pl : $!" +; while( <FILE> ) { print; } close FILE; } sub write_file { my ( $f, @data ) = @_; @data = () unless @data; open F, "> $f" or die "Can't open $f : $!"; print F @data; close F; } sub undefSub { no strict 'refs'; my $name = shift; # save the glob... local *old = *{$name}; # and restore everything else local *new; foreach my $type (qw(HASH IO FORMAT SCALAR ARRAY)) { my $elem = *old{$type}; next if !defined($elem); *new = $elem; } *{$name} = *new; }

In reply to Re: Stuck with Module::Reload et al. by £okì
in thread Stuck with Module::Reload et al. by £okì

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.