(defun perltidy () "Run perltidy on the current region or buffer." (interactive) (save-excursion (unless mark-active (mark-defun)) (shell-command-on-region (point) (mark) "perltidy --profile=/home/foo/.perltidyrc -q" nil t))) (global-set-key [(f5)] 'perltidy)