http://qs1969.pair.com?node_id=398159
Category: Miscellaneous
Author/Contact Info
Description:

If you use emacs, this function will check the syntax of your perl code and also run podchecker against it and display the result in a new buffer. You can call this function via the after-save-hook, and have the syntax checker run automatically. The function checks for CPerl mode.

Updated the code and the 'perlsyn' folder is shown only when there is a syntax error.(thanks to water)

Updated code to do a perl -wc (thanks to htoug)

;;my after-save-hook to cperl
(defun myperl-check-syntax ()
  (interactive)  
  (if (not (equal mode-name "CPerl"))
      ;;ignore
      ()
    ;;get the full path of this file
    (setq source-full-path (buffer-file-name))
    ;;clear the buffer of earlier error
    (set-buffer (get-buffer-create "perlsyn"))
    (erase-buffer)
    ;;set the perl5lib
    (setenv "PERL5LIB" "/usr/lib/perl5")
    ;;execute perl -wc
    (call-process "perl" nil "perlsyn" nil "-wc" source-full-path)
    ;;execute podchecker
;;    (call-process "podchecker" nil "perlsyn" nil 
;;                                                source-full-path)
    ;; checks if perl returned a syntax OK string
    (if (not (equal (substring (buffer-string) -3 -1) "OK"))
    (switch-to-buffer "perlsyn")))
  )

(add-hook 'after-save-hook 'myperl-check-syntax)