in reply to Detecting undefined subroutines at compile time
Perl detects undeclared subs (which is better than detecting undefined subs) at compile-time if you omit parens on sub calls.
>perl -c -e"use strict; sub f {} f;" -e syntax OK >perl -c -e"use strict; sub f; f;" -e syntax OK >perl -c -e"use strict; f;" Bareword "f" not allowed while "strict subs" in use at -e line 1. -e had compilation errors. >perl -c -e"use strict; sub g {} g 'abc';" -e syntax OK >perl -c -e"use strict; g 'abc';" String found where operator expected at -e line 1, near "g 'abc'" (Do you need to predeclare g?) syntax error at -e line 1, near "g 'abc'" -e had compilation errors.
Omitting parens on sub calls causes a whole of weird stuff, so I recommend against doing this.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Detecting undefined subroutines at compile time
by Anonymous Monk on May 04, 2011 at 17:07 UTC | |
by ikegami (Patriarch) on May 04, 2011 at 18:59 UTC |