[prog] perl woes...

Patricia Fraser trish at thefrasers.org
Sat May 31 16:19:15 EST 2003


Hi folks,

I'm wading through my project from the middle outwards, and trying to 
learn Perl as I go, so hopefully these questions aren't too muddy. I'm 
working on a CGI app that uses a MySQL database, Perl CGI scripts, 
Apache; the idea is for users to make selections from drop-down lists 
where there's data in tables, and then fill in form fields, and for the 
results of the lot to get written back to the database.

I have some of it working, with help from various sources, but I've 
struck a couple of snags - and if I'm not being explanatory enough, 
please shout!

First, I don't understand what's happening in a statement like 

$tmpl->param( supplist => \@suppliers );

I know what the result is - the actual value held in the hash to which 
the array refers gets pasted into a drop-down list in the template file 
I have set up. It works *fine*, and the drop-down list has all the 
right stuff in it. What I don't understand is *how*, so I can apply a 
principle elsewhere.

(code samples on request - too long to post in this mail!)

I guess there are a couple of things I don't understand; first, what 
"=>" does as opposed to what "->" does, but more to the point, what's 
actually happening when I'm tracking back through references (which 
I've figured out are actually memory addresses) to get back the stored 
value, which is what I want.

I'm also hoping for help with pointers to working out what 
templating system (if any) might be most helpful. I've read pretty much 
everything I can find, but some light-bulb moments would be lovely! 

I chose HTML::Template because of the looping thing, for populating 
drop-down lists, but it seems to have a drawback - I'd like the choices 
the user makes in the first two lists to be able to be plugged into the 
select statement for the third list, so the third list will only have 
data according to the first two choices. 

Seems like, once having decided to template at all, I have to move to a 
new page to display the third list, because I can't get the template to 
update the third list after the choices are made - ! I can update a 
page if I use a here-document, but that doesn't seem to allow me to 
populate the lists from the database. Grr!

I've got a thing working, with the extra-page way, but it seems a bit 
inelegant, and I'd really like to find out a solution to the problem 
anyway, because I'll need it again later...

There are more questions, but this is more than enough for now!

Cheers,

-- 
Trish Fraser, Sunbury, Australia
Linux user #283226  counter.li.org
cassiopeia up 25 days and counting
kernel 2.4.18-6mdk



More information about the Programming mailing list