Created
June 18, 2012 15:45
-
-
Save sugar84/2949008 to your computer and use it in GitHub Desktop.
search module
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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