perl.dict

vimとか使い出したのでとりあえずPerl用の辞書つくんなきゃなー、ってことで以下。

#!/usr/bin/perl

use warnings;
use strict;
use File::Find;

#use Readonly;
#Readonly my $perlfunc => q{Pod/Functions.pm};
my $perlfunc = q{Pod/Functions.pm};

my $perlfunc_path;
find(
        sub {
                $perlfunc_path = $File::Find::name
                if ( $File::Find::name =~ m/${perlfunc}$/ );
        },
        @INC,
);

print STDERR qq{perlfunc path : $perlfunc_path\n};
open( my $perlfunc_fh, q{<}, $perlfunc_path )
or die q{can't open perlfunc file.};

while (<$perlfunc_fh>) {
        last if (/^__DATA__$/);
}

while (<$perlfunc_fh>) {
        chomp;
        my $command = (split)[0];
        print qq($command\n) if ( $command =~ /^\w{1,}$/ );
}

print join( qq{\n}, qw{ if else elsif unless for foreach while until } )
. qq{\n};

リダイレクトしてperl.dictとかで保存、~/.vim/dictあたりにおいとく。元ネタは http://kaede.to/~canada/doc/vimeperlephpinoadhie なんだけど、ローカルにあるperlfunc利用するようにしてみた。多分Perl6以降でも使えるっしょ、てことで。