On Jul 15, Connie Chan said: >When Perl read my code, if in 'use' case, would it load everything >existed in my modules, and won't care on how I defined the use >and require method in my if (...) {...} case ?
Let's answer this by example. I'm going to produce several files here. ### ABC.pm package ABC; print "ABC\n"; sub ex { use DEF; require GHI; print "ABC::ex\n"; } 1; ### DEF.pm package DEF; print "DEF\n"; 1; ### GHI.pm package GHI; print "GHI\n"; 1; and finally: ### main.pl #!/usr/bin/perl print "1 main.pl\n"; # use ABC; # require ABC; ABC::ex(); print "2 main.pl\n"; Once you have all these files, uncomment "use ABC" and run main.pl. You should get the following output: DEF ABC 1 main.pl GHI ABC::ex 2 main.pl If you comment "use ABC" and uncomment "require ABC", you'll get output like this: 1 main.pl DEF ABC GHI ABC::ex 2 main.pl Can you see the difference? Because ABC.pm is REQUIRE()d, Perl doesn't even LOOK at the file until it gets to the require() statement, and THEN it executes the file. But because the file has a 'use' statement in it, that happens AS SOON as Perl looks at the file. -- Jeff "japhy" Pinyan [EMAIL PROTECTED] http://www.pobox.com/~japhy/ RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/ ** Look for "Regular Expressions in Perl" published by Manning, in 2002 ** <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course. [ I'm looking for programming work. If you like my work, let me know. ] -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]