Chapter 10. CryptoContext

Nathan Torkington

Perl is a language of acceptable subsets. Larry Wall has said many times that it’s okay not to know everything. If you know enough to get the job done, then obviously you know all you need.

The more you know about Perl, though, and the more of its features you use, the more you must understand how they work. When you put features together, they can often interact in surprising ways. This article explores the interaction between context, prototyping, and subroutine calls.

Tom Christiansen has long been in favor of reducing these interactions, namely by dropping context. In fact, he goes so far as to call it cryptocontext, and he came up with the challenge that prompted this article. Given these initial statements:

	sub f($$);

	@a = (5, 9);

Explain what each of these does, and why:







	f(@a, @a);



	f('ls /bin', 'ls /tmp');

	&f('ls /bin', 'ls /tmp');

Frightened that these may not do the obvious? Read on, and I’ll explain what happens.


Context is one of the gnarlier parts of Perl. While Tom is obviously anti-context, Larry Wall is a proponent of it (as he should be, since he put it into Perl in the first place). Larry is a linguist, and he tried to incorporate some of the features of successful natural languages in the hopes of making Perl a successful unnatural language. Context was one of those features.

When compiling and running your program, the Perl interpreter associates a context with ...

Get Computer Science & Perl Programming now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.