DCPM: $yntax
Matthew Browning
mb at simplepages.uklinux.net
Tue Jul 23 05:41:04 CDT 2002
Can anyone put me straight here? I can't seem to think right:
I have two arrays, both of thirteen elements. These values contained
therein need to be massaged into a hash for passing to a method (which
wants them like that, not written by me)
So, the arrays are like:
@array1 = ('one', 'two', 'three' etc...
@array2 = ('dog', 'cat', 'pig' etc...
and I want them to wind up in a hash looking like this:
my %edit_vars = (
[-- other stuff --]
values => \@pass_to,
);
Now, I can make it work, as implied above, by doing this:
my @pass_to = (
{ left => $array1[0],
right => $array2[0] },
{ left => $array1[1],
right => $array2[1] },
{ left => $array1[2],
right => $array2[2] },
...and so forth,
But that is pretty inelegant and, while I *know* it to be wrong, I am
afraid I can't see the Right Thing here, perhaps as a result of recent
nocturnal excesses.
Data structure spaghetti.
Anyone know what I'm on about? How would you do it?
MB (curiously, with the song `Play That Funky Music, White Boy' going
around in his head 24 hours a day)
More information about the Devoncornwall-pm
mailing list