Skip to content

Instantly share code, notes, and snippets.

@sugar84
Created June 18, 2012 15:45
Show Gist options
  • Save sugar84/2949008 to your computer and use it in GitHub Desktop.
Save sugar84/2949008 to your computer and use it in GitHub Desktop.
search module
#!/usr/bin/env perl
use common::sense;
my $module = $ARGV[0];
$| = 1;
die "wrong module name: $module" if $module !~ /^[A-Za-z0-9:]+$/;
my @parts = split "::", $module;
$parts[$#parts] .= ".pm";
for my $search_dir (@INC) {
my $fname = join "/", $search_dir, @parts;
if (-f $fname) {
say $fname;
my $read_key = <STDIN>;
exec "vim " . $fname;
}
}
warn "$module is not found";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment