Perl/TkFAQ-12.6use和require有什么区别?

王朝perl·作者佚名  2008-05-18
窄屏简体版  字體: |||超大  

原文:

12.6. What is the difference between use and require?

The short answer is that something like: use Tk;

is equivalent to: BEGIN { require "Tk.pm"; import Tk; }

Hence the essential difference is that a mere require Tk; does not achieve the import of function/method names. The significance of this is that it allows one to call ->Button rather than having to call the fully qualified ->Tk::Button e.g.. For further details on this subject see man perlmod(1) or see Tom Christiansen's document at: ftp://ftp.perl.com/perl/info/everything_to_know/use_vs_require

译文:

12.6 use和require有什么区别?

简单的说,下面的语句:

use Tk;

等价于:

BEGIN { require “Tk.pm”; import Tk;}

所以,它们最本质的区别就在于,仅仅require Tk;语句并没有导入相应对象的函数(方法)名。这一点的意义在于,它就使我们可以直接使用诸如->Button的方法,而不必使用完全的包名- >Tk::Button等等。关于这个主题的更详细的讨论,可以参阅perlmod的手册,或者可以参阅Tom Christiansen's的文档:

ftp://ftp.perl.com/perl/info/everything_to_know/use_vs_require

 
 
 
免责声明:本文为网络用户发布,其观点仅代表作者个人观点,与本站无关,本站仅提供信息存储服务。文中陈述内容未经本站证实,其真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。
 
 
© 2005- 王朝網路 版權所有 導航