这个Perl模块有什么问题? [英] What's wrong with this Perl module?
问题描述
我正在制作一个非常非常简单的模块(这是我写过的第一个模块):
I am making a very, very simple module (it is the first I've ever wrote):
package Master::Math;
use 5.12.4;
use strict;
use warnings;
require Exporter;
our @ISA = qw(Exporter)
our %EXPORT_TAGS = (
'all' => [ qw(
max
=cut
1; # End of Master::Math
当我在程序中使用它时,出现错误
When I run use this in my program, I get the error
无效的版本格式(非数字数据)位于C:/Perl/lib/Master/Math.pm第3行, 靠近包Master :: Math
Invalid version format (non-numeric data) at C:/Perl/lib/Master/Math.pm line 3, near "package Master::Math
" C:/Perl/lib/Master/Math.pm第3行中的语法错误,靠近包Master :: Math
" syntax error at C:/Perl/lib/Master/Math.pm line 3, near "package Master::Math
需要出口商" 编译在C:\ MainDev \ myperl \ max.pl第3行中的require失败. BEGIN失败-在C:\ MainDev \ myperl \ max.pl第3行中中止编译.
require Exporter" Compilation failed in require at C:\MainDev\myperl\max.pl line 3. BEGIN failed--compilation aborted at C:\MainDev\myperl\max.pl line 3.
我需要解决什么问题?谢谢!
What do I need to fix this? Thanks!
推荐答案
您在@ISA
的声明中缺少分号.
You're missing a semicolon on the declaration of @ISA
.
在sub max
中,未声明$foo
;使用foreach my $foo ...
.
那应该可以编译它.我没有超越.
That should get it to compile. I haven't looked beyond that.
(顺便说一句,我没有得到与您相同的错误.我使用的是Perl 5.14.0,perl -cw master-math.pm
.)
(BTW, I didn't get the same errors you did. I used perl 5.14.0, perl -cw master-math.pm
.)
这篇关于这个Perl模块有什么问题?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!