||For those who edit with emacs, here are a couple of functions that I find useful. The first one runs perl on the current region, replacing it with the results of the command. The second does the same for the current buffer.
Both functions attempt to preserve the current locations of point and mark as best they can. In the case of updating the entire buffer, the point and mark maintain the same line & column number, if possible.
I'm not an elisp guru; suggestions and improvements welcome!
Inspired by a one-liner in TPJ by Dominus.
; run perl on the current region, updating the region
(defun perl-replace-region (start end)
"Apply perl command to region"
(shell-command-on-region start end
(read-from-minibuffer "Replace region comma
+nd: " '("perl -pe \"\"" . 11 ))
; run perl on the current buffer, updating the buffer
(defun perl-replace-buffer ()
"Apply perl command to buffer"
(let ((ptline (count-lines (point-min) (point)))
(command (read-from-minibuffer "Replace buffer command: " '("p
+erl -pe \"\"" . 11 ))))
(setq markline (count-lines (point-min) (point)))
(setq markcol (current-column))
(let ((new-start (region-beginning))
(shell-command-on-region new-start new-end command t t )