[Israel.pm] A Perl 5 Gotcha

Offer Kaye offer.kaye at gmail.com
Sun Mar 8 01:44:47 PST 2009


On Fri, Mar 6, 2009 at 9:41 AM, Gaal Yahas wrote:
> Another is near the top of the file to say:
>
> main() if !caller;
> sub main {
>    # ...
>    exit 0;
> }
>

By wrapping the main body of the file in a subroutine of itself you've
restricted the scope of the (lexical) $filename to no longer be
file-wide, thus causing a compilation error (vs. the previous run-time
error) when $filename is called inside print_filename.
This much I understand.

But what does "if !caller" have to do with it?

-- 
Offer Kaye



More information about the Perl mailing list