Thread abgedrehtes problem mit switch: oder bin ich blind?
(71 answers)
Opened by deepblack at 2004-06-16 21:56
[quote=sri,03.07.2004, 04:05][quote=Dieter,03.07.2004, 01:57][quote=steffenw,02.07.2004, 22:10]Was man in einen BEGIN-Block schreibt, was macht mod_perl dann, nur einmal oder immer wieder?[/quote]
BEGIN { } ist nichts anderes als eine ganz normale Subroutine. Der Block wird also nicht anders compiliert als jeder andere Teil des Scripts auch.[/quote] Ich werde das jetzt nicht korrigieren, aber fairneshalber gebe ich dir einen Hinweis. "perldoc perlmod"[/quote] A "BEGIN" subroutine is executed as soon as possible, that is, the moment it is completely defined, even before the rest of the containing file is parsed. You may have multiple "BEGIN" blocks within a file--they will execute in order of definition. Because a "BEGIN" block executes immediately, it can pull in definitions of subroutines and such from other files in time to be visible to the rest of the file. Once a "BEGIN" has run, it is immediately undefined and any code it used is returned to Perl's memory pool. This means you can't ever explicitly call a "BEGIN". |