jonas@paranormal.o.se (Jonas Liljegren) wrote > There is a incinsistent change of behaviour between v5.005_03 and v5.6.0 > > Only v5.005_03 calls END for this: > > #!/usr/local/bin/perl > END {print "After\n"} > priint "error"; > __END__ This is a deliberate change. From "perldoc perldelta": END blocks and the `-c' switch Prior versions used to run BEGIN and END blocks when Perl was run in compile-only mode. Since this is typically not the expected behavior, END blocks are not executed anymore when the `-c' switch is used. Hmmm.. wait a moment - that doesn't actually cover the case you quote. Seems like the attached doc patch is needed. Mike Guy --- ./pod/perldelta.pod.orig Mon Apr 24 17:28:32 2000 +++ ./pod/perldelta.pod Mon Apr 24 17:04:39 2000 @@ -1811,7 +1811,7 @@ Prior versions used to run BEGIN B<and> END blocks when Perl was run in compile-only mode. Since this is typically not the expected behavior, END blocks are not executed anymore when the C<-c> switch -is used. +is used, or if compilation fails. See L<CHECK blocks> for how to run things when the compile phase ends. --- ./pod/perlmod.pod.orig Mon Mar 13 21:25:37 2000 +++ ./pod/perlmod.pod Mon Apr 24 17:29:42 2000 @@ -233,7 +233,7 @@ (if you can).) You may have multiple C<END> blocks within a file--they will execute in reverse order of definition; that is: last in, first out (LIFO). C<END> blocks are not executed when you run perl with the -C<-c> switch. +C<-c> switch, or if compilation fails.. Inside an C<END> subroutine, C<$?> contains the value that the program is going to pass to C<exit()>. You can modify C<$?> to change the exit @@ -252,7 +252,7 @@ When you use the B<-n> and B<-p> switches to Perl, C<BEGIN> and C<END> work just as they do in B<awk>, as a degenerate case. As currently -implemented (and subject to change, since its inconvenient at best), +implemented (and subject to change, since it's inconvenient at best), both C<BEGIN> and<END> blocks are run when you use the B<-c> switch for a compile-only syntax check, although your main code is not. End of patch