ところで、前のエントリのperlsubで、気になる一文を見つけたのです。
Note, however, that the ``&'' is NOT optional when you're just naming the subroutine,
such as when it's used as an argument to defined() or undef().
え、definedとundefって、関数を引数に渡せるの!? 早速試してみると・・・。
use strict;
sub test{ die "definedやundefでは呼び出されません"; }
print defined &test ? 'Y' : 'N' , "\n";
print defined &hoge ? 'Y' : 'N' , "\n";
undef &test;
print defined &test ? 'Y' : 'N' , "\n";
test(); # be dying
【結果】
Y
N
N
Undefined subroutine &main::test called at - line 11.消えてるみたいですね。これをうまく使うと、こんな時でも、mod_perl下でキャッシュされたコンパイル済の関数を削除できるかも?? 試してませんけど…c(゜^ ゜ ;)。