perl live coding
Emacs Lisp Perl
Switch branches/tags
Nothing to show
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Failed to load latest commit information.
README.md
perl-live.el
perl-live.pl
unreliable.el

README.md

perl live coding

usage

; put perl-live.el and perl-live.pl 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 perl-live.pl 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.

customize

(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/perl-live.pl") ; path to interpreter script - default: "perl-live.pl" at same dir where you put perl-live.el
(defvar perl-live-switches "/path/to/perl-live.pl") ; default: "-g" - make "my" global

requirements

perl

emacs

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 perl-live.pl -g # run
# enter perl code
# hit Ctrl+D on a new line to evaluate
#     Ctrl+C to interrupt

elsewhere