While I'm on the subject of shell scripting ...
How often have you wanted to cut n paste a module name from some error message onto the command line and just edit the damned file? Isn't it a huge pain in the arse changing all the :: into slashes?
function vi {
VI=/usr/bin/vim
INARGS=("$@")
OUTARGS=()
for i in ${INARGS[@]}; do
if echo $i|grep ::>/dev/null; then
OUTARGS=(${OUTARGS[@]} `echo $i.pm|sed 's/::/\//g'`)
else
OUTARGS=(${OUTARGS[@]} $i)
fi
done
$VI ${OUTARGS[@]}
}
There, I fixed it :-) Now you can do this and it'll Just Work:
$ vi lib/MyApp::Module::That::Is::Broken
how about doing this instead:
vi $(perldoc -l Some::Module)
perldoc -l will find the first copy of that module in the search path, which may not be the copy I'm working on. In fact, it's pretty much guaranteed to not be the one I'm working on. eg ...
$ perldoc -l Number::Phone::UK /usr/local/lib/perl5/site_perl/5.8.8/Number/Phone/UK.pm
this is no good when I'm in $HOME/perlmodules/Numer-Phone and want to edit lib/Number/Phone/UK.pm. My ugly hack lets me type:
vi lib/[paste]
This is bash, yes? Try this on for size:
Aristotle ... you need to drop a .pm on the end tho
Ah yes.