紧急求助:perl代码差错。多谢多谢啦!
时间:2011-04-29
来源:互联网
说是有逻辑或语法错误,但是我都看不出来,觉得没啥问题,请有经验的TX指点下啦!多谢了!
There are errors in the following code, both in logic
and in syntax. Find the errors and provide the correct
fixes.
# this function prints something to stdout, unless
# the option parameter is set to STDERR, and then it
# prints out to stderr
sub writeOut
{
my $message = shift;
my $option = shift; #optional
if( $option eq 'STDERR' )
{
print STDERR $message . "\n";
}
else
{
print $message . "\n";
}
}
# this function gets the system UUID, with or without
# dashes depending on the option
sub getUUID()
{
my $option = shift; #optional
my $uuid = "8f5de6fd-5f97-4b27-be35-861c3bbbb1f1";
if( $option eq 'nodash' )
{
$uuid =~ s/-//g;
}
return $uuid;
}
There are errors in the following code, both in logic
and in syntax. Find the errors and provide the correct
fixes.
# this function prints something to stdout, unless
# the option parameter is set to STDERR, and then it
# prints out to stderr
sub writeOut
{
my $message = shift;
my $option = shift; #optional
if( $option eq 'STDERR' )
{
print STDERR $message . "\n";
}
else
{
print $message . "\n";
}
}
# this function gets the system UUID, with or without
# dashes depending on the option
sub getUUID()
{
my $option = shift; #optional
my $uuid = "8f5de6fd-5f97-4b27-be35-861c3bbbb1f1";
if( $option eq 'nodash' )
{
$uuid =~ s/-//g;
}
return $uuid;
}
作者: bubulife 发布时间: 2011-04-29
here
QUOTE:
sub getUUID()
{
my $option = shift; #optional
{
my $option = shift; #optional
作者: zhlong8 发布时间: 2011-04-29
能请你进一步解释一下么?到底是哪里有错了?多谢啦!
作者: bubulife 发布时间: 2011-04-29
知道啦,你是说不应该有括弧是吧。
哎呀,真是糊涂了,我一直在想函数里面的语句没有问题啊!!!
多谢啦。
那第一段代码有什么问题呢?
哎呀,真是糊涂了,我一直在想函数里面的语句没有问题啊!!!
多谢啦。
那第一段代码有什么问题呢?
作者: bubulife 发布时间: 2011-04-29
回复 bubulife
第一个没什么问题,第二个你是用 () 声明了不需要参数,然后又在代码里面取参数。我从没这么用过,这个应该算逻辑错误吧
第一个没什么问题,第二个你是用 () 声明了不需要参数,然后又在代码里面取参数。我从没这么用过,这个应该算逻辑错误吧
作者: zhlong8 发布时间: 2011-04-29
相关阅读 更多
热门阅读
-
office 2019专业增强版最新2021版激活秘钥/序列号/激活码推荐 附激活工具
阅读:74
-
如何安装mysql8.0
阅读:31
-
Word快速设置标题样式步骤详解
阅读:28
-
20+道必知必会的Vue面试题(附答案解析)
阅读:37
-
HTML如何制作表单
阅读:22
-
百词斩可以改天数吗?当然可以,4个步骤轻松修改天数!
阅读:31
-
ET文件格式和XLS格式文件之间如何转化?
阅读:24
-
react和vue的区别及优缺点是什么
阅读:121
-
支付宝人脸识别如何关闭?
阅读:21
-
腾讯微云怎么修改照片或视频备份路径?
阅读:28