in reply to Re^5: My problems to understand the Perl documentation
in thread My problems to understand the Perl documentation

Yes, good point, I was thinking of e.g. if and for, but I didn't list goto but did list return - now that I think about it some more, I probably shouldn't have listed the latter because it can't really be approximated by a sub (that's how I personally generally differentiate between "functions" and "operators" in Perl, but this isn't perfect and a pretty big grey area).

Replies are listed 'Best First'.
Re^7: My problems to understand the Perl documentation (Terminology)
by LanX (Saint) on Aug 24, 2020 at 19:46 UTC
    In my book

    • (named) function something of the form Name(Args) usable as EXPR, that means returning a value at runtime. Parens can be omitted if precedence is clear. Arguments - if any - must follow to the right, either as one UNARY value or as comma separated LIST.
    • builtin : a named function in the language core. The name is a reserved keyword. Some may have special parsing rules for arguments and special context, such that they can't be replicated with sub (PROTOTYPE) { BLOCK }
    • operator symbols acting like functions by returning values but with "surrounding" (not necessarily following) arguments, special parsing and precedence like 2 * 3 . See perlop and overload
    • named operators like xor have an alphanumeric IDENTIFIER as "symbol". NB: some builtin functions are sometimes documented as "operators" (it's just a huge subgroup with a more standard syntax)
    • statement keywords anything requiring void context. I.e. can't be used in an expression (without do ). It usually follows a semicolon and is used for side-effects . Most at compile time like like use
    • Some of them are documented as "function-like keywords" because they parse like functions like my but are primarily used for declaration (a compile time side effect)

    Please expand/correct me. ..

    EDIT

    N.B. some keywords fall into multiple categories, depending on usage.

    sub name { Block } is a statement declaring a subroutine at compile time.

    $code = sub { Block }; is a builtin function returning a coderef at runtime.

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery

Re^7: My problems to understand the Perl documentation
by LanX (Saint) on Aug 26, 2020 at 21:33 UTC
    To make things more complicated...

    Took a look into

    CORE

    and there "built-in functions" and "keywords" are used as synonyms. :/

    Cheers Rolf
    (addicted to the Perl Programming Language :)
    Wikisyntax for the Monastery