in reply to web form processing - efficiency question
The only thing you lose by moving to a hash is the ordering of the keys, but you can get that back:
Then to generate the HTML in the right order is not so bad (not that I'm a big fan of this -- you should be using a templating system anyway):my $question = { descriptions => { m => "male", f => "female", o => "other" }, choices => [ qw/m f o/ ] }
And validating choices becomes trivial:for my $choice ( @{ $question->{choices} } ) { my $text = $question->{descriptions}{$choice}; print qq[<option value="$choice">$text</option>\n]; }
Anyway, having an array of arrays, with inner arrays having just 2 items, is a good sign that a hash (or certainly a relation matrix) might be in order.$valid = exists $question->{descriptions}{$answer};
blokhead
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Re: web form processing - efficiency question
by nmerriweather (Friar) on May 07, 2004 at 01:10 UTC | |
by knoebi (Friar) on May 07, 2004 at 08:24 UTC | |
by nmerriweather (Friar) on May 07, 2004 at 18:27 UTC |