Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
initial import of Module-Reload 1.05 from CPAN
git-cpan-module: Module-Reload git-cpan-version: 1.05 git-cpan-authorid: JPRIT git-cpan-file: authors/id/J/JP/JPRIT/Module-Reload-1.05.tar.gz
- Loading branch information
Showing
4 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
Reload.pm | ||
MANIFEST | ||
README | ||
Makefile.PL |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
use ExtUtils::MakeMaker; | ||
|
||
WriteMakefile(NAME => "Module::Reload", | ||
VERSION_FROM => "./Reload.pm"); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
=head1 NAME | ||
|
||
AutoReloader - Reload %INC files when updated on disk | ||
|
||
=head1 SYNOPSIS | ||
|
||
AutoReloader->check; | ||
|
||
=head1 DESCRIPTION | ||
|
||
When Perl pulls a file via C<require>, it stores the filename in the | ||
global hash C<%INC>. The next time Perl tries to C<require> the same | ||
file, it sees the file in C<%INC> and does not reload from disk. This | ||
module's handler iterates over C<%INC> and reloads the file if it has | ||
changed on disk. | ||
|
||
Set $AutoReloader::Debug to enable debugging output. | ||
|
||
=head1 DIRECTION | ||
|
||
It is expected that this will be included in the main perl | ||
distribution shortly. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
use strict; | ||
package Module::Reload; | ||
use vars qw($VERSION $Debug %Stat); | ||
$VERSION = "1.05"; | ||
|
||
sub check { | ||
my $c=0; | ||
while (my($key,$file) = each %INC) { | ||
next if $file eq $INC{"Module/Reload.pm"}; #too confusing | ||
local $^W = 0; | ||
my $mtime = (stat $file)[9]; | ||
$Stat{$file} = $^T | ||
unless defined $Stat{$file}; | ||
if ($mtime > $Stat{$file}) { | ||
delete $INC{$key}; | ||
require $key; | ||
if ($Debug) { | ||
warn "Module::Reload: process $$ reloading $key\n" | ||
if $Debug == 1; | ||
warn("Module::Reload: process $$ reloading $key (\@INC=". | ||
join(', ',@INC).")\n") | ||
if $Debug > 1; | ||
} | ||
++$c; | ||
} | ||
$Stat{$file} = $mtime; | ||
} | ||
$c; | ||
} | ||
|
||
1; | ||
|
||
__END__ | ||
=head1 NAME | ||
Module::Reload - Reload %INC files when updated on disk | ||
=head1 SYNOPSIS | ||
Module::Reload->check; | ||
=head1 DESCRIPTION | ||
When Perl pulls a file via C<require>, it stores the filename in the | ||
global hash C<%INC>. The next time Perl tries to C<require> the same | ||
file, it sees the file in C<%INC> and does not reload from disk. This | ||
module's handler iterates over C<%INC> and reloads the file if it has | ||
changed on disk. | ||
Set $Module::Reload::Debug to enable debugging output. | ||
=head1 SEE ALSO | ||
mod_perl, Event, ObjStore | ||
=head1 AUTHOR | ||
Copyright © 1997-1998 Doug MacEachern & Joshua Pritikin. All rights reserved. | ||
This package is free software and is provided "as is" without express | ||
or implied warranty. It may be used, redistributed and/or modified | ||
under the terms of the Perl Artistic License (see | ||
http://www.perl.com/perl/misc/Artistic.html) |