On 10/4/02 at 9:46 AM, [EMAIL PROTECTED] (Will) wrote:

> Greets Folks,
> 
> I have been reading the following tutorial on loops
> constructs, and I cant tell for sure, but I think I
> found an error.  At any rate it is confusing me, so I
> thought I would ask.  
> 
> Here' the tutorial link: 
> 
> http://html-template.sourceforge.net/article.html
> 
> Specifically, after the loops example the tutorial
> explains ---> First, the data is included in the form
> of a hash of arrays ---
> 
> Now, my question is... is that right?  I mean, it
> looks more like an array of hashes, and, secondly, I
> found another tutorial which seems to indicate it is
> an array of hashes.
> 

Taking the whole paragraph in context (especially note the last
sentence):

Inside the script we have a more complicated situation. First, the data
is included in the form of a hash of arrays. Each key is the name of a
fruit and the values are two-item arrays. Each array contains a color
value and shape value. This is just an example - any reasonable data
structure could have been used.

This is the data that we are starting with. You might start with data
from a text file, MySQL, user input etc. And then you would put it into
a Perl data structure. Like it says "any reasonable data structure could
have been used"

Reading on in Sams tutorial:

The loop that takes the fruit data and puts it into @loop comes next.
The ultimate goal here is to produce something like:


   [
     { name => 'Apple',   color => 'Red',    shape => 'Round' },
     { name => 'Orange',  color => 'Orange', shape => 'Round' },
   ]

This array-of-hashes format is what HTML::Template needs to fill in a
<TMPL_LOOP>. Each row of the array corresponds to a pass through the
<TMPL_LOOP>, and each key/value pair is a <TMPL_VAR> assignment to be
made. To get to this format the script uses push() to build up the @loop
array, adding a hash-ref for each fruit.


I think you are just confusing the fact that Sam started with an
arbitrary perl data structure, as if to say, 'Let's say we have some
data like this...'.

And then in his script he creates array of hashes that will be passed to
the template. (Does that make sense?)

> 
> P.S. A bit OT here... but, in perl,does the => symbol
> have a specific name?  I know what it does generally,
> i.e. it is often used to help define hash, but all I
> can think of to call it is an "equals-arrow", so a
> more appropriate name is probably wanting.
> 
> 
> 
infix operator?


-------------------------------------------------------
This sf.net email is sponsored by:ThinkGeek
Welcome to geek heaven.
http://thinkgeek.com/sf
_______________________________________________
Html-template-users mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/html-template-users

Reply via email to