Username: Password:

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

喜欢本文,那就收藏到:

    Del.icio.us Google书签 Digg Live Bookmark Technorati Furl Yahoo书签 Facebook 百度搜藏 新浪ViVi 365Key网摘 天极网摘 和讯网摘 博拉网 POCO网摘 添加到饭否 QQ书签 Digbuzz我挖网
相关评论  我也要评论
还没有关于此文章的相关评论!
  • 昵称: (为空则显示guest)
  • 评论分数: ★ ★ ★★★ ★★★★ ★★★★★
  • 评论内容:(不能超过250字,需审核后才会公布,请自觉遵守互联网相关政策法规。
  • 导航
    赞助商
    文章类别
    订阅