in reply to Re: Calling functions in middle of CGI HTML declarations
in thread Calling functions in middle of CGI HTML declarations
The functions tend to take arguments on a per element basis. If the function is going to it will generally ask if it is recieveing an array or hash reference first then go on to process the code accordingly.
The important thing is to provide the method with what it is expecting or is set up to handle. Here it is important to determine to the method it is being provided with an array reference rather than an expanded list. As it will determine whether the list is going to be concatenated and used as content as in the case where the array actual is used and ends up as one chunk in the div, or split into the lists components and then used as content, where the ref is used and creates the individual divs.
The square brackets provide the method with an anonymous array built from the list provided in the array, whereas the reference to the array provides, a reference to the array. Providing the reference being the more efficient way to move the data through.
I think that building an anonymous array out of a named array (what I did by adding square brackets)is probably more expensive than needs be, but was a workaround to get the desired result.
Basically if you provide the array as a reference, the method does the foreach for you. But you have to inspect each method via the docs to determine what each will or wont accept. There can be differnces in output depending on which markup or version you are using and such.
To note, while hacking through this I noticed that closed div beginning elements were produced which is some effect of the code being processed for xhtml and not html, hence the start_div/end_div in the foreach statement to explicitly inform cgi what I wanted. This also prevented the divs being built recursively within themselves without any closing elements.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^3: Calling functions in middle of CGI HTML declarations
by Your Mother (Archbishop) on Aug 27, 2012 at 00:04 UTC | |
by Don Coyote (Hermit) on Aug 27, 2012 at 09:14 UTC |