Perl/TkFAQ-12.6use和require有什么区分?
来源:linux宝库作者:linux宝库 发布时间:2007-09-30 00:00:00

原文:
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
|
还没有关于此文章的相关评论!