develooper Front page | perl.perl5.porters | Postings from June 2003

Re: [perl #22826] AutoReply: use does not work as documented with respect to CHECK and INIT

From:
pcg
Date:
June 26, 2003 18:16
Subject:
Re: [perl #22826] AutoReply: use does not work as documented with respect to CHECK and INIT
Message ID:
20030627011636.GA13268@schmorp.de
On Fri, Jun 27, 2003 at 01:04:22AM -0000, perlbug-followup@perl.org wrote:
>    use XYZ;
>    # CHECK and INIT get run
> 
>    require XYZ;
>    # CHECK and INIT blocks _never_ run, not even at program end.
> 
> So it seems that require keeps CHECK and INIT from running at all.

Correction: If I use BEGIN around the require, they indeed get run:

   perl -e 'BEGIN { require Board }'
   perl -e 'BEGIN { require "kgsueme/board.pl" }'

However, my program driver was loading the main program using a require:

   require "otherfile";

and when otherfile did the require on Board.pm, the CHECK and INIT
callbacks never got run, not even after leaving the code executed in
require.

-- 
      -----==-                                             |
      ----==-- _                                           |
      ---==---(_)__  __ ____  __       Marc Lehmann      +--
      --==---/ / _ \/ // /\ \/ /       pcg@goof.com      |e|
      -=====/_/_//_/\_,_/ /_/\_\       XX11-RIPE         --+
    The choice of a GNU generation                       |
                                                         |



nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About