Perlbrew minimal emacs util
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.



This is a minimal perlbrew utility for emacs. It does only the minimal things : computing the path to various perl binaries, and setting exec-path and PATH accordingly.


basic usage

In your .emacs :

(require 'perlbrew-mini)

By default this will try to find perlbrew perls from $HOME/perl5/pelbrew/perls/. It will then try to use the latest perl found in that directory. You can override the various options below:

To override the perlbrew directory:

;; by default perlbrew-mini-set-perls is set to $HOME/perl5/pelbrew/perls/
(perlbrew-mini-set-perls-dir "/home/username/path/to/perl5/perlbrew/perls/")

To override which perlbrew perl version to use:

;; by default it will use the latest perl (alphanumeric comparison on the file name)
(perlbrew-mini-use "perl-5.12.2")

Once loaded, perlbrew-mini provides these functions:

perlbrew-mini-get-current-perl-path ;; returns the current perl path
perlbrew-mini-get-current-version ;; returns the current perl version in use

See below for a real life example

with flymake and cperl-mode

This is an example to use flymake with perlbrew. This method will make flymake create its temporary file in the same directory than the Perl source file it's examinating.

Warning, for this to work you need to install Project::Libs inside the perlbrew you wish to use.

(require 'perlbrew-mini)
(perlbrew-mini-use "perl-5.12.2")
(require 'flymake)

(defun flymake-perl-init ()
  (let* ((temp-file (flymake-init-create-temp-buffer-copy
         (local-file (file-relative-name
                      (file-name-directory buffer-file-name))))
    (list (perlbrew-mini-get-current-perl-path)
          (list "-MProject::Libs" "-wc" local-file))))

(add-hook 'cperl-mode-hook (lambda () (flymake-mode t)))

If you'd like flymake to create its temporary files in a temporary directory instead, please see