On Tue, Dec 1, 2009 at 10:56 PM, Ludwig Isaac Lim <[email protected]> wrote:
>
>   Can we say closures are anonymous coderefs that acesses a pre declared 
> variable?

Nahuli na ba ako? :-) In Perl, a closure is just a subroutine that has
access to persistent private variables. It can either be a named subroutine
or anonymous subroutine.

A named closure is usually used to get the same effect of static variables
in C and it's usually enclosed in a BEGIN{} block to make sure that
the private variables they refer to are available at compile time. The BEGIN{}
block is not needed for subroutines that are part of a package (Perl modules),
because it will be evaluated at compile time when the package is use-d.

HTH
_________________________________________________
Philippine Linux Users' Group (PLUG) Mailing List
http://lists.linux.org.ph/mailman/listinfo/plug
Searchable Archives: http://archives.free.net.ph

Reply via email to