in reply to Re: Re: Scope and Context
in thread Scope and Context

The reason for the embedding of the subroutine within the code at this point is so that the regular expressions in the file are loaded entirely within the BEGIN {} block. Yes I can still call the subroutine from this point, but for my own mindset, I like keeping such initialisation code in the one place.

You could put the sub definition in the BEGIN block...

Replies are listed 'Best First'.
Re: Re: Re: Re: Scope and Context
by pdcawley (Hermit) on Nov 14, 2001 at 20:02 UTC
    If you're never going to call the sub from outside the BEGIN block then maybe something like:
    BEGIN { my $get_regexes = sub { ... return map {...} }; ... }
    Which has the advantage of keeping the subroutine private.

    Oh yes, don't forget that in recent perl you can do open my $fh, ..., which is far nicer than

    local *FH; open FH, ...