diff options
Diffstat (limited to 'helpers/perl')
| -rw-r--r-- | helpers/perl | 21 |
1 files changed, 14 insertions, 7 deletions
diff --git a/helpers/perl b/helpers/perl index f847dc74..2a01a096 100644 --- a/helpers/perl +++ b/helpers/perl @@ -2,12 +2,13 @@ use strict; use Config; +use Cwd; use File::Spec::Functions; my %seen; sub print_modules_real { - my ($base, $dir, $word) = @_; + my ($base, $dir, $word, $include_pod) = @_; # return immediately if potential completion doesn't match current word # a double comparison is used to avoid dealing with string lengths @@ -23,8 +24,9 @@ sub print_modules_real { chdir($dir) or return; # print each file - foreach my $file (glob('*.pm')) { - $file =~ s/\.pm$//; + foreach my $file (sort(glob('*.pm'),glob('*.pod'))) { + next if ($file =~ /\.pod$/ and not $include_pod); + $file =~ s/\.(?:pm|pod)$//; my $module = $base . $file; next if $module !~ /^\Q$word/; next if $seen{$module}++; @@ -36,19 +38,21 @@ sub print_modules_real { my $subdir = $dir . '/' . $directory; if ($directory =~ /^(?:[.\d]+|$Config{archname}|auto)$/) { # exclude subdirectory name from base - print_modules_real(undef, $subdir, $word); + print_modules_real(undef, $subdir, $word, $include_pod); } else { # add subdirectory name to base - print_modules_real($base . $directory . '::', $subdir, $word); + print_modules_real($base . $directory . '::', $subdir, $word, $include_pod); } } } sub print_modules { - my ($word) = @_; + my ($word, $include_pod) = @_; + my $origdir = getcwd; foreach my $directory (@INC) { - print_modules_real(undef, $directory, $word); + print_modules_real(undef, $directory, $word, $include_pod); + chdir $origdir; } } @@ -86,4 +90,7 @@ if ($type eq 'functions') { print_functions($word); } elsif ($type eq 'modules') { print_modules($word); +} elsif ($type eq 'perldocs') { + print_modules($word, 1); } + |
