module
A file that defines a package of (almost) the same name, which can either export symbols or function as an object class. (A module's main .pm file may also load in
other files in support of the module.) See the use built-in.
一个定义了和包相同名字的文件
package
A namespace for global variables, subroutines, and the like, such that they can be kept separate from like-named symbols in other namespaces. In a sense, only the
package is global, since the symbols in the package's symbol table are only accessible from code compiled outside the package by naming the package. But in another
sense, all package symbols are also globals--they're just well-organized globals.
一个包是是存储,全局变量,子函数,依次类推。
,只有包是全局的,他们可以用类似的符号放在不同的名字空间。
有一个观念,只有包是全局的。
一个perl文件(一般以.pm结尾)就可以称为一个模块了。
一个包的定义可以跨多个模块,一个模块中也可以有多个包定义。
当你适用package时,你在为你自己的变量,方法提供一个容身之所
perl 包和模块
最新推荐文章于 2021-06-25 13:01:53 发布
Perl中的模块(.pm文件)定义了一个与包同名的命名空间,用于导出符号或作为对象类。包则是一个全局的命名空间,用于隔离全局变量和子例程,使其在不同命名空间中保持独立。模块可以包含其他支持文件,包内的符号通过指定包名来访问,它们是组织良好的全局符号。
摘要由CSDN通过智能技术生成