Category: | Utility Scripts |
Author/Contact Info | (reply) |
Description: | Use 'vi' as your 'pager' to view module source code.
This is a bit like "perldoc -m Module" then "v" to tell your pager (if it is smart enough) to throw you into your favorite editor (but less typing, supports multiple module names, leaves the paths to the modules displayed after you exit the editor, doesn't require your pager support "v", etc.) Requires Algorithm::Loops. (Updated to remove mispelt "pathes". Thanks, gaal.) |
#!/usr/bin/perl -w use strict; use Algorithm::Loops qw( Filter MapCarE ); Main( @ARGV ); exit( 0 ); sub Main { my @mods= @_; die "Usage: $0 Module::Name [...]\n" if ! @mods; my @files= Filter { s#::#/#g; s#'#/#g; $_ .= ".pm" if ! /\./; } @mods; my @paths= MapCarE { my( $mod, $file )= @_; if( ! eval { require $file; 1 } ) { warn "No such module ($mod); $file not found.\n"; (); } else { $INC{$file}; } } \@mods, \@files; exit( 1 ) if ! @paths; my $vi= $ENV{VISUAL} || $ENV{EDITOR} || "vi"; print STDERR "Running $vi...\n"; system( $vi, @paths ); print $_, $/ for @paths; } |
|
---|