开发者

Perl explicitly using module UNIVERSAL causes a module to not export any symbols

开发者 https://www.devze.com 2023-02-15 19:06 出处:网络
I have two perl modules where one is the \"object base\" and the other imports functions from this \"object base\" module. When I compile the second module (perl -c Foo/Bar/NewObject.pm) it compiles w

I have two perl modules where one is the "object base" and the other imports functions from this "object base" module. When I compile the second module (perl -c Foo/Bar/NewObject.pm) it compiles without any warnings.

The issue is if I include the UNIVERSAL module in compiling the second module (perl -MUNIVERSAL -Mstrict -wc Foo/Bar/NewObject.pm) it throws warnings like:

"set" is not exported by the Foo::Bar::Object module

So my question is why does including UNIVERSAL cause the Exporter function to fail exporting symbols from the 'object base' model?

An example of what the modules look like are below.

object base:

#!/usr/bin/perl -w  

use strict;  

package Foo::Bar::Object;

use Exporter;

our @ISA = qw(Exporter);

our @EXPORT = qw( new set get update create  );

... 

1;开发者_StackOverflow中文版

second module:

#!/usr/bin/perl -w  

use strict;  

package Foo::Bar::NewObject;

use Foo::Bar::Object qw( new set get );

... 

1;


I ended up resolving this by follow what @ikegami linked in the comments. I had to wrap the @EXPORT in a BEGIN {} block and that seemed to work.

There must have been a module trying to use the methods before they were exported.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号