in reply to Re^2: How to identify incorrect subroutine calls in a perl program
in thread How to identify incorrect subroutine calls in a perl program
You can't tell if it's invalid; at best you could say that it might be invalid.
if( $phase_of_moon eq 'gibbous' or $customer_account->balance > 867_5309 ) { eval qq{package est; sub Log { print LOG "Awooooooo: ", @_ }}; }
Is it valid now? If you looked at the symbol table, you'd think no. But will it be valid the next time the program's run? How about the 2034th time you run it?
Granted you possibly could write something to grobble over the parse tree and compare that with defined subs from the symbol table and then warns for things it doesn't see there. I don't know of anything that does that offhand though.
And really I don't know if there'd be much call for it. Presumably you hit this error once, corrected it, and moved on. Just like any other run-time error in your code; the only difference from more conventional syntax errors is that you hit it at runtime rather than at perl -wc foo.plx time. Such is the price you pay for flexibility.
Update: And the unit testing aficionados would chime in that you of course have tests which exercise all of the paths through your code so something would hit the offending code right out of the gate. :)
Update: Added something to "Granted ..." to hopefully clear up wording.
|
|---|