What's wrong with this Perl module?

2019-07-27 10:14发布

问题:

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

Invalid version format (non-numeric data) at C:/Perl/lib/Master/Math.pm line 3, near "package Master::Math

" syntax error at C:/Perl/lib/Master/Math.pm line 3, near "package Master::Math

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!

回答1:

You're missing a semicolon on the declaration of @ISA.

In sub max, $foo is undeclared; use foreach my $foo ....

That should get it to compile. I haven't looked beyond that.

(BTW, I didn't get the same errors you did. I used perl 5.14.0, perl -cw master-math.pm.)