Didn't know that, thanks. Which blocks exactly work this way except I know about: BEGIN, UNITCHECK, CHECK, INIT, END, AUTOLOAD, DESTROY
| [reply] |
Hello hurricup,
Which blocks exactly work this way...[?]
There is a non-exhaustive list in perlsub, introduced as follows:
Subroutines whose names are in all upper case are reserved to the Perl core, as are modules whose names are in all lower case. A subroutine in all capitals is a loosely-held convention meaning it will be called indirectly by the run-time system itself, usually due to a triggered event.... The following is a list of some subroutines that currently do special, pre-defined things.
Note also:
The BEGIN, UNITCHECK, CHECK, INIT and END subroutines are not so much subroutines as named special code blocks, of which you can have more than one in a package, and which you can not call explicitly.
By contrast, AUTOLOAD is a (special) subroutine:
13:43 >perl -MO=Deparse -we "AUTOLOAD { 'First' } AUTOLOAD { 'Second'
+}"
Subroutine AUTOLOAD redefined at -e line 1.
BEGIN { $^W = 1; }
sub AUTOLOAD {
'Second';
}
-e syntax OK
13:43 >
Hope that helps,
| [reply] [d/l] [select] |