library(perlbrewr)
knitr::opts_chunk$set(
  echo = TRUE,
  comment = "#>"
)
perlbrew(root = params$perlbrew_root, version = params$perl_version)

Installed perls

perlbrew_list(root = params$perlbrew_root, include.libs = FALSE)

Some perl code

Perl code can now be written that uses the specific interpreter with version r params$perl_version as part of the perlbrew installation in r params$perlbrew_root.

use strict;
use warnings;
use feature 'say';
say "Hello World";
say "perl is: $^X";

Using a library for analysis

A local::lib is easily created to allow for user level installation and enhance reproducibility of a workflow by using a cpanfile to install dependencies with cpanm.

success <- perlbrew_lib_create(root = params$perlbrew_root,
                               version = params$perl_version,
                               lib = "template",
                               perlbrew.use = TRUE)
available <- perlbrew_list(root = params$perlbrew_root)
attr(available, "active")

Knitr has already been updated to use the PERL5LIB by setting engine.opts.

Chunks interpreted with Bash will also have the correct environment to do what I mean (DWIM).

which perl
which cpanm
echo $PERL5LIB

In this way any perl scripts that have dependencies, may have these dependencies met by using cpanm to install the modules from CPAN using the cpanfile that was included with the script :tada:.



kiwiroy/perlbrewr documentation built on May 2, 2020, 7:45 a.m.