This is logical follow-up to my previous post about K shortcut.
The two (actually three lines) added to ~/.vimrc allow when editing Perl and VIM scripts to transparently call with K proper help system.
au BufReadPost *.pl set keywordprg=perldoc\ -f
au BufReadPost *.vim map K :exe ":help ".expand("<cword>")<CR>
au BufReadPost .vimrc map K :exe ":help ".expand("<cword>")<CR>
Perl one is obvious. VIM one actually required some trickery: we do not call external program, but call VIM's internal command instead.
:help :helpis pretty useful reading. Due to my error, 'K' in VIM mode used to constantly show it, instead of expected 'expand("<cword>")'.