PracticeDev/study_perl/perl_model_Foo.pm

21 lines
612 B
Perl
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

#!/usr/bin/perl
# note
# Perl5 中用Perl包来创建模块。
# Perl 模块是一个可重复使用的包,模块的名字与包名相同,定义的文件后缀为 .pm。
# Perl 中关于模块需要注意以下几点:
# 函数 require 和 use 将载入一个模块。
# @INC 是 Perl 内置的一个特殊数组,它包含指向库例程所在位置的目录路径。
# require 和 use 函数调用 eval 函数来执行代码。
# 末尾 1; 执行返回 TRUE这是必须的否则返回错误。
package Foo;
sub bar {
print "Hello $_[0]\n"
}
sub blat {
print "World $_[0]\n"
}
1;