Beefy Boxes and Bandwidth Generously Provided by pair Networks
more useful options

Re^2: Calling functions in middle of CGI HTML declarations

by Don Coyote (Monk)
on Aug 26, 2012 at 18:17 UTC ( #989862=note: print w/ replies, xml ) Need Help??

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.

Comment on Re^2: Calling functions in middle of CGI HTML declarations
Re^3: Calling functions in middle of CGI HTML declarations
by Your Mother (Canon) on Aug 27, 2012 at 00:04 UTC

    Did you silently update your original reply or did I just completely miss the parts that are similar to mine? If I did miss it, sorry about that.

      YM, no, no silent update. I kind of felt like mentioning that using the backslash ref notation as in your example is most likely a better way to use a ref overall. Though without proper tests I cannot really tell as I do not know.

      I replied also to make the point the method is looking for a ref to produce the op requirements, whether a ref to an anonymous array or an actual array ref. And is also why I replied to your thread rather than again to the ot

      hope this clears up what I was blabbering on about

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://989862]
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (14)
As of 2014-07-23 11:06 GMT
Find Nodes?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:

    Results (140 votes), past polls