Perl では、関数に定数を渡してから定数の名前を文字どおりに表示し、その値を使用することは可能ですか? ある種のエスケープされた定数名を関数に渡すことでしょうか?
これは私がやりたいことの例です。もちろん、 exitError() のコードはまだ私がやりたいことをしていません。
use constant MAIL_SEND_FAILED => 1;
# exitError($exitcode)
sub exitError
{
my $exitCode = $_[0];
say "error, exitcode: $exitCode"; # output constant name as human readable exitcode, e.g. MAIL_SEND_FAILED
exit $exitCode; # use value of exitcode, e.g. 1
}
exitError(MAIL_SEND_FAILED);
# function call should effectively execute this code
# say "error, exitcode: MAIL_SEND_FAILED";
# exit 1;