cmac has asked for the wisdom of the Perl Monks concerning the following question:
Items in @items2show are identified by a set of global subscript constants near the start of the script, one of which might besub handler { my @items2show; ... checkForm (..., \@items2show); ... showPage (..., \@items2show); ... }
One of the things that checkForm wants to pass to showPage in @items2show is an array that's anonymous other than being passed by reference as items2show[ARRAYX]. Near the start of checkForm the overall items2show array is initialized. Later in checkForm, value(s) want to be pushed onto the ARRAYX array.use constant ARRAYX => 3;
I've tried various syntaxes in the push statement above, and cannot get Perl to accept any of them. Also I'm not clear on whether the initializer for the ARRAYX array wants to be [] or (), although this can be worked thru if I can get the push syntax right...sub checkForm { my (..., $items2show_ref) = @_; @$items2show_ref = (); $$items2show_ref[ARRAYX] = []; # should this be () ?? ... push @??ARRAYX??, $value; ... }
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: getting in trouble avoiding global variables
by webfiend (Vicar) on Dec 09, 2008 at 00:25 UTC | |
|
Re: getting in trouble avoiding global variables
by GrandFather (Saint) on Dec 09, 2008 at 00:46 UTC | |
by cmac (Monk) on Dec 09, 2008 at 08:56 UTC | |
|
Re: getting in trouble avoiding global variables
by BrowserUk (Patriarch) on Dec 09, 2008 at 00:23 UTC | |
|
Re: getting in trouble avoiding global variables
by ww (Archbishop) on Dec 09, 2008 at 01:45 UTC |