memo.xight.org

日々のメモ

chalowの CPAN 検索プラグイン

CPAN 検索プラグイン

### CPAN Moduleの検索リンク
# usage: {{cpan_search('Keyword','mode')}}
# mode : all    - Search in All
#        dist   - Search in Distributions
#        module - Search in Modules (default)
#        author - Search in Author
sub cpan_search {
	my ($word,$mode) = @_;
	my $prefix = q(http://search.cpan.org/search);
	if ($mode ne 'all' && $mode ne 'dist' && $mode ne 'author' && $mode ne 'module'){
		$mode = q(all);
	}
	return qq(<a href="$prefix?m=$mode&q=$word" title="CPAN Search - $word">$word</a>);
}
sub cpan{cpan_search(@_)}