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

5 Comments

how about doing this instead:

vi $(perldoc -l Some::Module)

This is bash, yes? Try this on for size:

vi() { command vi "${@//:://}" ; }

Aristotle ... you need to drop a .pm on the end tho

Ah yes.

vi() { set -- "${@//:://}" ; command vi "${@/%/.pm}" ; }

Leave a comment

About David Cantrell

user-pic I'm in yur test resultz analyzn yr failz