作者:zjl_perl 中国Perl协会 (2005-06-28 10:24:21)
你是否觉得perl中关于模块的文档有些难懂?好的,这里有一个世界上最简单的模块,它将用于展示(demonstrate)Exporter模块所有的特性,另外还有一段使用这个模块的脚本。同时,我们也会给出一个有关于@INC的简短说明,最后,还要讲一下有些关于using warnings和use模块的使用。
下面是这个模块的内容:
MyModule.pm
package MyModule;
use strict;
use Exporter;
use vars qw($VERSION @ISA @EXPORT @EXPORT_OK %EXPORT_TAGS);
$VERSION = 1.00;
@ISA = qw(Exporter);
@EXPORT = ();
@EXPORT_OK = qw(func1 func2);
%EXPORT_TAGS = ( DEFAULT => [qw(&func1)],
Both => [qw(&func1 &func2)]);
sub func1 { return reverse @_ }
sub func2 { return map{ uc }@_ }
1; Read the rest of this entry »