Perl is a great reporting language. It just happens to be inconvenient to run reports and get them into a text editor so I can look at them. This fixes that by making it easy to run perl scripts and have the output show up in a new buffer.

Usage. This creates functions for your scripts so the function to call is up to you.

M-x nab-duplicate-usernames

An example copied from my .emacs file.

;; Domino address book stuff (perl-script nab-duplicate-employeeids "Fetch duplicate NAB employeeids" "Notes\\NAB\\DuplicateEmployeeIDs.pl") (perl-script nab-mismatch-employeeid-case "Fetch employeeids with mismatched case (AggDb vs NAB)" "Notes\\NAB\\MismatchCase.pl") (perl-script nab-duplicate-employeeids-harder "Fetch duplicate NAB employeeids harder" "Notes\\NAB\\DuplicateEmployeeIDsHarder.pl") (perl-script aggregation-duplicate-employeeids "Fetch duplicate Aggregation Db usernames" "Notes\\NAB\\AggDb-DuplicateEmployeeIDs.pl") (perl-script nab-duplicate-usernames "Fetch duplicate NAB usernames" "Notes\\NAB\\DuplicateUsernames.pl") (perl-script nab-inactive-users-in-nab "Fetch ex-employees in the NAB" "Notes\\NAB\\GDInactiveInNAB.pl")

Add the perl-script macro and some configuration variables to your .emacs file.

;; Wrap perl scripts with emacs (setq perl-program "C:\\perl\\bin\\perl.exe") (setq perl-script-path "C:\\usr\\local\\bin\\") (defmacro perl-script (name description executable) `(defun ,name () ,description (interactive) (let ((buf (generate-new-buffer ,(symbol-name name)))) (shell-command ,(concat perl-program " " perl-script-path executable) buf) buf)))

Replies are listed 'Best First'.
Re: Wrap perl scripts in emacs
by bluto (Curate) on Sep 23, 2004 at 17:20 UTC
    This is nice, ++.

    One minor note: Under Unix if you don't require a specific perl binary or a specific script path and would like to have emacs just locate them in your PATH, just make them executable and add a shebang to them. You can then run them with a reduced version like this...

    ;; Wrap perl scripts with emacs (defmacro perl-script (name description executable) `(defun ,name () ,description (interactive) (let ((buf (generate-new-buffer ,(symbol-name name)))) (shell-command ,executable buf) buf)))
    ... in order to get rid of the two path globals. This isn't much different than using M-x shell-command directly, but it does give you an easy way to use a unique buffer with a useful name.