I’m reading Beginning Perl by Simon Cozens and in Chapter 8 – Subroutines he states that “subroutines” are user functions, while print, open, split, etc. are built-in operators or functions.
What are they? Are they really built-in, language-intrinsic features (like C’s sizeof operator) or are they, actually, subroutines/functions of the main module?
If they’re subroutines, are while, for, unless, etc. also subroutines? What about the operators like +, -, eq, etc.?
print,open,splitare not subroutines. They do not result in sub calls. They are not even present in the symbol table (inmain::or otherwise, although you can refer to them asCORE::split, etc), and one cannot get a reference to their code (although work is being done to create proxy subs for them inCORE::for when you want to treat them as subroutines). They are operators just like+.They are known by a variety of names:
And most are considered to be one of the following:
Subroutines are often called functions (as they are in C and C++), so “function” is an ambiguous word. This ambiguity appears to be the basis of your question.
As for
while,for,unless, etc, they are keywords used by flow control statementsand statement modifiers