找不到对象方法“new”通过包“A :: B” [英] Can't locate object method "new" via package "A::B"

查看:85
本文介绍了找不到对象方法“new”通过包“A :: B”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我收到以下错误:

软件错误:

无法找到对象方法new通过包A :: B在/path/file.cgi第5行。


我的代码基本上是这样的:

I''m getting the following error:
Software error:
Can''t locate object method "new" via package "A::B" at /path/file.cgi line 5.

My code is basically this:

展开 | 选择 | 换行 | 行号

推荐答案

希望您的模块代码中包含更多内容,并且缺少@EXPORT语句等内容。


我认为您需要阅读一个优秀的Perl模块制作教程。那个非常好,来自这个类型的信息的优秀网站。


问候,


杰夫
Hopefully your module code has more in it as well as it is missing things like the @EXPORT statements and such.

I think you need to read a good Perl module making tutorial. That one is pretty good and from an excellent site for that type of information.

Regards,

Jeff


你不会是第一个认为他们的人他们使用他们发布的代码来发现他们错了。主要脚本是找到A :: B模块,而不是方法new。因此,请仔细检查模块A :: B中用于从浏览器运行主脚本的服务器是否正在访问您认为的A :: B模块。如果是新的方法在模块中并正确编码我不明白为什么它不适用于您发布的那个简单示例。
You wouldn''t be the first person that thought they were using the code they posted to find out they were mistaken. The main script is finding the A::B module, just not the method "new". So double-check that in the module A::B that the server you are using to run the main script from the browser is accessing the A::B module you think it is. If the "new" method is in the module and coded correctly I don''t see why its not working for that simple example you posted.


非常感谢您的回答! numberwhun:我肯定会在某些时候检查你的链接。


我同意看起来似乎没有访问正确的A :: B模块。但是,我有点认为代码是正确的(所以也许我不应该发布它),因为相同的代码对我的同事有效。


是:我的老板决定我们需要使用一些我们无法在Windows下工作的软件包,所以我们不得不切换到Mac(或Linux,但我们的盒子都是双启动Mac / Windows)。所以现在我必须在Mac OS X下完成所有工作。因为我认为代码必须正确,我正在寻找更多的答案,如果当你试图让Perl(模块)在Mac下工作时OS X Leopard,您必须将环境变量XYZ设置为ABC,或者可能在Perl / CPAN / Apache /中设置一些配置。我不确定它是不是那样的,而且我在Perl和Mac OS X都是菜鸟,但我认为它应该是那样的。 (顺便说一下,@ INC变量确实包含正确的目录)


再次感谢您的回答!
Thank you both very much for your answers! numberwhun: I''ll be sure to check out your link sometimes.

I agree that it seems that it would seem that not the correct A::B module is accessed. However, I kind of have an idea that the code is right (so maybe I shouldn''t have posted it), because the same code does work for my colleague.

The thing is: my boss decided that we needed to use some package that we can''t get to work under Windows, so we had to switch to Mac (or Linux, but our boxes are all dual boot Mac/Windows). So now I have to get everything to work under Mac OS X. Since I think the code must be right, I''m looking more for an answer along the lines of "When you try to get Perl (modules) working under Mac OS X Leopard, you have to set environment variable XYZ to ABC, or maybe some configuration in Perl/CPAN/Apache/whatever". I''m not sure if it''s something like that, and I''m both a noob at Perl and Mac OS X, but I figure that it should be something like that. (BTW, the @INC variable thing does include the right directories)

Thanks again for any answers!


这篇关于找不到对象方法“new”通过包“A :: B”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆