sub totol{ my $max; #這個前面一定要加my,否則上次使用過的值還會存在,因為是全域變數 chomp @_; foreach(@_){ $max+=$_; } $max; } <!-- more -->