Clear questions and runnable code get the best and fastest answer |
|
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
I could loop over the hash and build up the array, but I would like to be more clever and use the map { } function. I'd like to step back for a moment. This node is interesting, and the map solutions are very neat and clever. I know we all like writing this kind of code. It's certainly exciting when you can look at a block of code like this and understand what it's doing. I have to wonder if it's the best approach, though. An iterative solution would be easier to write, and easier to read later, saving time on both ends. I guess it's a moot point now that the clever solutions have been provided, but it might be worth thinking about. Incidentally, if the thing you don't like about the iterative solution is that you have to use push instead of having everything as an rvalue (which I admit, does feel kind of clumsy), then I have good news for you. This is yet another thing Fixed in 6:
The gather/take construct allows you to use an iterative algorithm as an rvalue. I think I will end up using it a lot. :-) Update: some may point out that map really is iterative, just in a sort of interesting way. I guess that's true. So perhaps s/iterative/for loop/g on my node. In reply to Re: Specific hash to array conversion query
by revdiablo
|
|