in reply to Re: Detecting undefined subroutines at compile time
in thread Detecting undefined subroutines at compile time

Grasshopper, you can determine undefined subroutines at compile time just as soon as you have plucked the Halting Problem from the palm of my hand:
no strict; no warnings; no less tricky; foo(lish); his::bar(tab); silly->stuff; come on, please give up; package UNIVERSAL; sub AUTOLOAD { print "I am masquerading as $AUTOLOAD(@_)\n" }
yields when run:
I am masquerading as main::foo(lish) I am masquerading as his::bar(tab) I am masquerading as silly::stuff(silly) I am masquerading as on::come(on) I am masquerading as give::please(give up)

Replies are listed 'Best First'.
Re^3: Detecting undefined subroutines at compile time
by LanX (Saint) on May 03, 2011 at 07:41 UTC
    Did he really ask for undefined methods? Those calls are per definition only resolved at runtime.

    Despite manipulating UNIVERSAL in your example, the functions foo() and bar() are still found by B::Xref

    $ perl -MO=Xref,-r tst.pl|grep subused tst.pl (main) 2 main & foo + subused tst.pl (main) 3 his & bar + subused ...

    I agree that every approach can be somehow tricked out, but IMHO the vanilla cases are well covered by B::Xref.

    Cheers Rolf