免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
最近访问板块 发新帖
查看: 8823 | 回复: 3
打印 上一主题 下一主题

Too many arguments 的错误大家遇到过么?有无什么解决办法 [复制链接]

论坛徽章:
0
跳转到指定楼层
1 [收藏(0)] [报告]
发表于 2006-09-22 09:01 |只看该作者 |倒序浏览
Too many arguments 的错误大家遇到过么?有无什么解决办法
root@test # perl -we "sub NOP(){};NOP('a')"
Too many arguments for main::NOP at -e line 1, at end of line
Execution of -e aborted due to compilation errors.

我程序里边遇到同样的错误,网上搜到相同的简单的报错的例子!

论坛徽章:
0
2 [报告]
发表于 2006-09-22 09:14 |只看该作者

找到答案了!好像很简单的错误

when you say
sub pa () {
...

you say that there is a function pa expecting 0 arguments

if you say
sub pa {
...

you say that there is a function pa with ANY number of arguments

so you should remove the () from the function definition.


-- Gabor


On 2001.07.24 15:56 Arie Abramovitch wrote:
> Hi
>
> I have 2 files: my.pl and ub.pm.
>
> The script pub.pm. contains the function pa() definition as follows:
> ---------------------------------------------------------
> sub pa ()
> {
>          pa_profile(0, scalar(@_), \@_);
> }
> ---------------------------------------------------------
>
> The script my.pl calls the function pa()  as follows:
> ---------------------------------------------------------
> pa ( 0, 1, 2, 3, 4, 5, 6, 7, 8, 9);
> ---------------------------------------------------------
>
> The problem:
> When I try to run my.pl script, PERL fails with a compilation error:
> Too many arguments for pub::pa at my.pl line 25, near "9)"
>
> I moved the definition of pa() to the script my.pl and PERL runs ok.
>
> My question:
> Why did PERL complain in the first case?
> Why did it stop complaining after placing the function in my.pl?
> What should I do to run the pa() function in its original place (in
> pub.pm)?
>
> Thanks,

论坛徽章:
1
2015年辞旧岁徽章
日期:2015-03-03 16:54:15
3 [报告]
发表于 2006-09-22 09:14 |只看该作者
你给 NOP 加了原型说明,但是又不按照原型走,不知道你到底想要干什么……

论坛徽章:
0
4 [报告]
发表于 2006-09-22 09:25 |只看该作者
to: flw
不管你有多牛,不要用训斥别人口吻讲话
别人也只是一时疏忽了,当然也是理解不深!平时主要工作不是编程,所以研究不够深!
遗憾呀!毕业后没有走到想走的编程的路上!
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP