Sometimes, I realize that I'm chasing my own tail... but I just can't stop myself. :) I'm hoping my fellow Monks will help me with this particular chase; it's not all that important, but it's driving me nuts.
I have an array (returned by a dereferenced "selectcol_arrayref" from DBI::mysql, but that's not important) that consists of a set of triples - one "key" item and two "values". What I want to do is to use the key as a key in a hash, and the two other items as elements in an arrayref which will be the value. What I'm doing right now is
# @ref is the returned array for ( 0 .. $#ref / 3 ){ my $m = $_ * 3; $out{$ref[$m]} = [ @ref[$m+1, $m+2] ]; }
but I can't get rid of the feeling that there's a prettier, more elegant, more *Perlish* way to do it. Even more, it's not an unusual requirement in programming, and it just irks me that my brain is refusing to give up the answer.
So, fellow hackers - what's your answer? I'd really appreciate someone else's input on this, since my own creative juices seem to be exhausted here.
In reply to Elegance, dammit! by oko1
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |