defined(&func) and Exporter


Why are subroutines resulting from constants imported with Exporter are not considered to be defined?

$ perl -MFcntl -le 'print &F_SETLK'

shows that a subroutine F_SETLK can be called. But

$ perl -MFcntl -le 'print "undefined" unless defined &F_SETLK'

shows that it is not considered to be defined.

The consequence is that a constant imported this way can accidentely be overridden by a 'require ""'.

eval 'sub F_SETLK () {6;}' unless defined(&F_SETLK);

but &F_SETLK is not considered to be defined after the use()age of Fcntl and is thus overridden.

Peter Michael's original post