Skip to content

Perlbrew In Shell Scripts

Kang-min Liu edited this page Sep 13, 2011 · 8 revisions

Perlbrew In Shell Scripts

Since 0.29 release of perlbrew, it is much easier to invoke perlbrew function in the shell script. Specifically the perlbrew use and perlbrew switch commands. Here's an example bash script:

#!/bin/bash

## These 3 lines are mandatory.
export PERLBREW_ROOT=/opt/perlbrew
export PERLBREW_HOME=/tmp/.perlbrew
. ${PERLBREW_ROOT}/etc/bashrc

## Do stuff with 5.14.1
perlbrew use 5.14.1
perl /app/my-modern-program

## Do stuff with 5.12.3
perlbrew use 5.12.3
perl /app/my-legacy-program

In short: definde PERLBREW_ROOT and PERLBREW_HOME before including the perlbrew bashrc file.

Clone this wiki locally