我写的程序如下:
#!/usr/bin/perl
print max(45..121,12..23)."\n";
print max(23..34,356..564)."\n";
sub max{
my($max)=shift(@_);
foreach $temp (@_){
if $temp > $max
$max=$temp;
}
return($max);
}
运行时提示出错,我检查了好几遍,实在查不出那里出错了
提示如下:
Scalar found where operator expected at print.pl line 9, near "$max
$max"
(Missing operator before $max?)
syntax error at print.pl line 8, near "if $temp "
Execution of print.pl aborted due to compilation errors.
大家帮看看那里错了
谢谢 |