perl 包和模块

72 篇文章 31 订阅 ¥39.90 ¥99.00
Perl中的模块(.pm文件)定义了一个与包同名的命名空间,用于导出符号或作为对象类。包则是一个全局的命名空间,用于隔离全局变量和子例程,使其在不同命名空间中保持独立。模块可以包含其他支持文件,包内的符号通过指定包名来访问,它们是组织良好的全局符号。
摘要由CSDN通过智能技术生成
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时,你在为你自己的变量,方法提供一个容身之所

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值