App::perlzonji::Plugin::UseModule - Plugin to try the search word as a module name


App-perlzonji documentation Contained in the App-perlzonji distribution.

Index


Code Index:

NAME

Top

App::perlzonji::Plugin::UseModule - Plugin to try the search word as a module name

VERSION

Top

version 1.111500

SYNOPSIS

Top

    # perlzonji Devel::SearchINC

DESCRIPTION

Top

This plugin for App::perlzonji tries to use the search term as a module name. If the module can be loaded, it is added to the match results. In case the search term looks like a fully qualified function name such as Foo::Bar::some_function, the function part is stripped off the the remainder is tried again.

INSTALLATION

Top

See perlmodinstall for information and options on installing Perl modules.

BUGS AND LIMITATIONS

Top

No bugs have been reported.

Please report any bugs or feature requests through the web interface at http://rt.cpan.org/Public/Dist/Display.html?Name=App-perlzonji.

AVAILABILITY

Top

The latest version of this module is available from the Comprehensive Perl Archive Network (CPAN). Visit http://www.perl.com/CPAN/ to find a CPAN site near you, or see http://search.cpan.org/dist/App-perlzonji/.

The development version lives at http://github.com/hanekomu/App-perlzonji and may be cloned from git://github.com/hanekomu/App-perlzonji.git. Instead of sending patches, please fork this project using the standard git and github infrastructure.

AUTHORS

Top

COPYRIGHT AND LICENSE

Top


App-perlzonji documentation Contained in the App-perlzonji distribution.

use 5.008;
use strict;
use warnings;

package App::perlzonji::Plugin::UseModule;
BEGIN {
  $App::perlzonji::Plugin::UseModule::VERSION = '1.111500';
}

# ABSTRACT: Plugin to try the search word as a module name
use App::perlzonji;
App::perlzonji->add_trigger(
    'matches.add' => sub {
        my ($class, $word, $matches) = @_;
        my $try_module = sub {
            my $module = shift;
            eval "use $module;";
            !$@ && push @$matches, $module;
        };

        # try it as a module
        $try_module->($word);

     # if it contains '::', it's not a function - strip off the last bit and try
     # that again as a module
        $word =~ s/::(\w+)$// && $try_module->($word);
    }
);
1;
1;


__END__