in reply to Re^3: goto &sub and local question
in thread goto &sub and local question
If you plan on initializing %familySecrets, you need to use a BEGIN block if you are in main. In a module, this isn't necessary. Technically, you can use any one of the other special named blocks that run before your code: BEGIN, UNITCHECK, CHECK, or INIT. See perlmod for more details on these blocks.
{ my %familySecrets; BEGIN { %familySecrets = ( closet => 'skeleton', herbs_and_spices => 11, coke_recipe => 'sugar, water, shoe polish', ); } sub s1 { # Read family secrets } sub s2 { #write family secret #call s1 } }
TGI says moo
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^5: goto &sub and local question
by ikegami (Patriarch) on Nov 25, 2008 at 03:18 UTC | |
by TGI (Parson) on Nov 25, 2008 at 21:26 UTC | |
by ikegami (Patriarch) on Nov 26, 2008 at 00:18 UTC |