Perl &引用;最后一句话;函数的运算符?

Perl &引用;最后一句话;函数的运算符?,perl,Perl,Perl是否有用于退出函数的运算符,或者是否有用于函数的last sub f { # some code here if ($v == 10) { # goto end of function/exit function/last } # some code here } 一个goto可以做到这一点,但不知何故它错了?使用return

Perl是否有用于退出函数的运算符,或者是否有用于函数的
last

sub f {

    # some code here

    if ($v == 10) {
    # goto end of function/exit function/last
    }

    # some code here
}

一个
goto
可以做到这一点,但不知何故它错了?

使用
return好吧。。。可以使用转到子程序末尾:

sub f {

  # some code here

  if ($v == 10) {
    goto END;
  }

  # some code here
  END:
}
或用于跳到子程序末尾(如果添加块):

你真正想用的是


如果您想了解哪些函数可用,我将签出。

与几乎所有编程语言一样-
return将退出函数
sub f {
  END: {

    # some code here

    if ($v == 10) {
      last END;
    }

    # some code here

  } # END
}
sub f {

  # some code here

  if ($v == 10) {
    return;
  }

  # some code here

}