栏目列表
 
 
首页 > 操作系统 > Linux > Perl/Tk FAQ - 12.6 use和require有什么区别?
 

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

日期:2006-06-12 00:36:49  来源:网络转载
请您记住思索网的网址: http://www.4so.net  [加入收藏夹]

    
原文:

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
 
 
热门信息
 
相关文章