perl live coding
Emacs Lisp Perl
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

perl live coding


; put perl-live.el and in `/path/to/somewhere`
(add-to-list 'load-path "/path/to/somewhere")
(require 'perl-live)

Create cperl-mode buffer and use these keybindings:

  • "C-c C-l" - start live perl session
  • "C-c C-p" - stop it
  • "C-c C-c" - eval current line or region
  • "C-M-x" - eval everything between matching braces

Open *perl live* buffer in other frame/window to check output. Also, use *perl live* as REPL (comint-mode).

In order to have persistent variables between evals without magic, declare them using use vars qw($one @two %three) or use main package vars like: $'somevar or $::somevar or create other package on-the-fly. Modify if you want to preload other modules or predeclare context lexicals using my/state. By default my declarations at top level are converted to globals. Evaluating of 'use some_pragma' persists.


(defvar perl-live-bin "/path/to/perl") ; path to perl binary - default: "perl" or `perlenv-get-perl-path` if `perlenv.el` loaded
(defvar perl-live-script "/path/to/") ; path to interpreter script - default: "" at same dir where you put perl-live.el
(defvar perl-live-switches "/path/to/") ; default: "-g" - make "my" global




sample cperl-mode indentation config:

(setq cperl-close-paren-offset -4 cperl-continued-statement-offset 4
    cperl-indent-level 4 cperl-indent-parens-as-block t
    cperl-tabs-always-indent t cperl-indent-subs-specially nil)

usage without emacs

~$ perl -g # run
# enter perl code
# hit Ctrl+D on a new line to evaluate
#     Ctrl+C to interrupt