ipps, the interactive mode - a tutorial#

ipps, the interactive PetaPerl shell, is a shell for Perl: a prompt whose language is Perl. You type a line, pperl runs it and shows you the value, and everything the line declared is still there for the next one. It is the quickest way to try an expression, look inside a data structure, or find out whether a loop gets compiled.

You are assumed to know Perl. Nothing here needs installing: the prompt, its line editor and its history are built into the pperl binary.

Starting it#

pperl --shell

or, if you would rather type less, give pperl a second name once:

ln -s "$(command -v pperl)" ~/bin/ipps
ipps

pperl started under the name ipps is the interactive mode. A bare pperl without arguments is unchanged: it reads a program from standard input, as perl does.

Note

--shell needs a pperl built with the shell feature. A binary without it says so and stops. Check with pperl -V, which lists the features under PPERL_FEATURES.

The one idea#

A line at the prompt is Perl, compiled and run as it would be in a file, with one difference: what a line leaves behind stays. A my variable, a sub, a loaded module, a use strict, the current package - the next line starts where this one stopped.

ipps> my @primes = (2, 3, 5, 7)
(2, 3, 5, 7)
ipps> sub square { $_[0] ** 2 }
ipps> map { square($_) } @primes
(4, 9, 25, 49)

Everything else in this tutorial is a detail of that: how values are shown, what the commands that start with a colon do, how to make the prompt yours, and the few places where a line is not quite a file.

Chapters#