O'Reilly logo

Learning Perl, Second Edition by Randal L. Schwartz, Tom Christiansen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

D.10. Embeddible, Extensible

The "guts" of Perl are defined well enough that it becomes a relatively straightforward task to embed the Perl compiler/interpreter inside another application (such as has already been done with the Apache web server and the vi text editor), or to extend Perl by connecting it with arbitrary code written in C (or having a C-like interface). In fact, about a third of the online documentation for Perl is specifically devoted to embedding and extending Perl. The perlembed (1), perlapio (1), perlxs (1), perlxstut (1), perlguts (1), and perlcall (1) manpages cover these topics in depth.

And since Perl is freely reusable, you can write your proprietary spreadsheet application, using an embedded Perl to evaluate the expressions in your spreadsheet cells, and not have to pay one cent in royalties for all that power. Joy.

D.10.1. Security Matters

Perl was designed with security in mind. See Chapter 6 of Programming Perl or the perlsec (1) manpage about taint checking. This is the kind of security where you trust the writer of the program, but not the person running it, such as is often the case with setuid programs under UNIX, or server-launched programs anywhere. The Safe module, covered in the Safe(3) manpage and Chapter 7 of Programming Perl, provides something else entirely: the kind of security necessary when executing (as with eval) unchecked code.

D.10.2. Switch or Case Statements

No, Perl doesn't really have these, but it's easy to make them using ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required