I have a function that takes a fairly complex set of arguments, and am 
wondering if there is a better way of doing this than the way I have 
done. A call to the function, as I have it, looks like:

$network->potentiateWeights('network',1,(0,0,0,
                                         1,2,3,
                                         3,2,2));

where the list at the end is actually a set of 3 triples. To make it 
clearer, the function turns those parameters into the following XML 
(which is pretty much its job):
<PotentiateWeights change="1" net="network">
  <Weight src="0" dest="0" layer="0" />
  <Weight src="1" dest="2" layer="3" />
  <Weight src="3" dest="2" layer="2" />
</PotentiateWeights>

The arguments are processed using:
sub potentiateWeights {
    my $self = shift;   # for the OO-ness
    my $net = shift;
    my $delta = shift;
    my (@src, @dest, @layer);
    while (@_) {
        push @src, shift;
        push @dest, shift;
        push @layer, shift;
    }

Now, this works quite well, but doesn't seem all that right. I'd like to 
know how someone who had been using the language more than I would 
handle this situation. In particular, there is no way (excluding runtime 
checking) to ensure that there are the appropriate number of triples in 
the list.

Thoughts?

cheers,
-- 
Robin <[EMAIL PROTECTED]>                 JabberID: <[EMAIL PROTECTED]>

Hostes alienigeni me abduxerunt. Qui annus est?

PGP Key 0x776DB663 Fingerprint=DD10 5C62 1E29 A385 9866 0853 CD38 E07A 776D B663

Attachment: pgp00000.pgp
Description: PGP signature

Reply via email to