See more at EmacsWiki:CPerlMode
From Perl Hacks
(load-library "cperl-mode") (add-to-list 'auto-mode-alist '("\\.[Pp][LlMm][Cc]?$" . cperl-mode)) (while (let ((orig (rassoc 'perl-mode auto-mode-alist))) (if orig (setcdr orig 'cperl-mode)))) (while (let ((orig (rassoc 'perl-mode interpreter-mode-alist))) (if orig (setcdr orig 'cperl-mode)))) (dolist (interpreter '("perl" "perl5" "miniperl" "pugs")) (unless (assoc interpreter interpreter-mode-alist) (add-to-list 'interpreter-mode-alist (cons interpreter 'cperl-mode))))
(global-set-key "\M-p" 'cperl-perldoc) (cperl-set-style "PerlStyle") (setq cperl-close-paren-offset -4) (setq cperl-indent-parens-as-block t) (setq cperl-merge-trailing-else nil) (defadvice cperl-indent-command (around cperl-indent-or-complete) "Changes \\\\[cperl-indent-command] so it autocompletes when at the end of a word." (if (looking-at "\\>") (dabbrev-expand nil) ad-do-it)) (eval-after-load "cperl-mode" '(progn (require 'dabbrev) (ad-activate 'cperl-indent-command))) (defun perl-check-buffer () "check perl syntax of current buffer" (interactive) (shell-command-on-region (point-min) (point-max) "perl -c") ) (defun perl-eval (begin end) "Run selected region as perl code" (interactive "r") (shell-command-on-region begin end "perl")) (defun perl-prove () "Run the current test." (interactive) (shell-command (concat "prove -v " (shell-quote-argument (buffer-file-name))))) ;;(require 'cperl-mode) (define-key cperl-mode-map "\C-cc" 'perl-check-buffer) (define-key cperl-mode-map "\C-c\C-c" 'align-current) (define-key cperl-mode-map "\C-ct" 'perl-prove) (define-key cperl-mode-map "\C-ce" 'perl-eval)