Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Re: Multiple Data Selections per Field in CGI

by salvadors (Pilgrim)
on Jan 29, 2001 at 02:27 UTC ( [id://54904]=note: print w/replies, xml ) Need Help??


in reply to (jeffa) Re: Multiple Data Selections per Field in CGI
in thread Multiple Data Selections per Field in CGI

If the key exists, then is the value a scalar, or is it an array? If it's the first time the key is encountered, then the value is simply a scalar. The second time the key is encountered, it's still a scalar. The value needs to be converted to an array, and then the new value is added. Each time after that, simply push the new value to the already existing array:

You could also do this quite nicely with a tie:

package Quantum::Heisenberg; sub TIESCALAR { bless [], $_[0] } sub STORE { push @{$_[0]}, $_[1] } sub FETCH { my $self = shift; $self->[int rand @$self]; } 1;

Changing the FETCH method to do what you'd expect is left as an exercise for the reader ;)

Tony

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (2)
As of 2024-04-20 06:26 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found