- Perl allows us to change the meaning of programs in
an unusually large number of ways. (Of mainstream
languages, only C++ comes close in this respect. Mind you,
the C pre-processor gives you a lot of flexibility too.)
- Here's a partial list, to give you a flavour:
Language feature: |
Mechanism of mutability: |
Subroutine calls |
AUTOLOAD |
Module loading (use/require) |
Code references in @INC |
Regex syntax |
Overloaded qr// operator |
Input file syntax |
Source filters* |
Behaviour of builtins |
CORE::GLOBAL functions |
Variable semantics |
The tie mechanism |
Filehandle semantics |
tie , or PerlIO layers |
* It's very difficult to use source filters to implement mutation
in general, because you'd need a complete way to parse Perl code,
which is hard because of the context-dependence of the grammar.
(On the other hand, they're the only mechanism to use for translator
modules.)
- Other relevant language features include:
- Operator overloading
- Subroutine prototypes
- :Attributes
-
CHECK blocks
- Exporting functions to the caller's namespace
- The ability to go beyond the facilities of the language,
using
XS or Inline
- Symbol tables, special variables and so on
- >>
|