[EMAIL PROTECTED] wrote: > In a message dated 6/23/2006 12:30:35 P.M. Eastern Standard Time, > [EMAIL PROTECTED] writes: > >> hi charles -- >> >> In a message dated 6/22/2006 10:38:47 P.M. Eastern Standard Time, > [EMAIL PROTECTED] <mailto:[EMAIL PROTECTED]> writes: >> >> > BEGIN { >> > >> > my @pad = (some large list of numbers); >> > >> > ... >> >> >> just a point of curiosity... >> why is @pad defined inside a BEGIN block instead of just any old > block? >> >> regards -- bill walters > > a little more reflection is sometimes useful. > the answer, correct me if i'm wrong, is that placing @pad in a BEGIN > block closure > allows one to be sure that the array will be initialized before any of > the functions that > depend upon it are run, whereas if it was in an ordinary block closure > one could not > be so assured.
The fact that it's in a block allows it to be private to the accompanying subroutine. It doesn't have to be a BEGIN block unless you have other BEGIN blocks that may use it since it's initialized prior to any following code. If you were to place it later in the code, a BEGIN would be warranted. _______________________________________________ ActivePerl mailing list [email protected] To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs
