Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of rafael (2125)

Sunday June 22, 2003
02:52 PM

The Perl Jargon : cops

[ #12996 ]
Continuing our etymological exploration of perl's internals jargon... (NB. I'm not trying to produce some reference work here -- but rather to have some fun with some of the words that appeared in the perl dialect.) Today, as promised : What's a cop ?

In real life, you know what's a cop, don't you. Let's take traffic cops for example. Their job is, abstractly, to regulate the flow of cars. Well, in perl, that's the same thing. More or less. cop, in perl, stands for Control OPeration.

In more detail : when perl interprets a Perl script, it first compiles it into a syntax tree, in which nodes are called operations (or ops for short). Each op corresponds to a basic operation of the runtime interpreter : addition, file opening, method call, etc. and there are many types of ops (unary, binary, list...) A cop basically corresponds to a semicolon in a perl source code : it's a checkpoint between two separate statements. At each control op, perl stores the current source file name and line number, the compiler hints (e.g. which set of strictures are in effect), the current lexical warnings in use, a potential loop label, etc. So cops, well, passively regulate control flow. (OK, they're more like roadsigns than actual cops. Anyone wants to propose a better parallel?)

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.