One More Thing

After compiling my todo list for followme yesterday, I remembered there's one more module that needs to be written. I need a module that will generate an rss or atom feed for recently changed files in a directory. The most likely use is with together with the blog module (App::Followme::CreateNews) but there's no reason it couldn't be used for other folders. Which is why I'll write it as a separate module.

Followme loads and runs the modules that are listed in the configuration file, which allows you to change the behavior of the script without changing the code. Here's the source code for the subroutine that loads and runs modules:

sub load_and_run_modules {
    my ($self, $modules, $base_directory, $directory, %configuration) = @_;
    foreach my $module (@$modules) {
        eval "require $module" or die "Module not found: $module\n";
        $configuration{base_directory} = $base_directory;
        my $object = $module->new(\%configuration);
        $object->run($directory);
    }  
    return;
}

The trick for loading a module at run time is on the eval line. The eval is necessary if the module name is not a bareword or a string constant. The base directory is the directory containing the configuration file, while the directory is what the module is being run on. These can be the same or different, depending on which directory followme is being run from.