![]() |
|
Perl Monk, Perl Meditation | |
PerlMonks |
My 'perldar' tells me there is a 'better' solution for this list operationby OfficeLinebacker (Chaplain) |
on Nov 03, 2006 at 22:28 UTC ( #582186=perlquestion: print w/replies, xml ) | Need Help?? |
OfficeLinebacker has asked for the wisdom of the Perl Monks concerning the following question:
Greetings, esteemed monks! I have two lists, one of which is a subset of the other. So for example, I want to end up with a list that is the same length as @l1, but every value that is not also present in @l2 should be replaced with "null". What I have so far: I'm thinking there has to be a more elegant and/or efficient and/or more robust way. perhaps something like
I guess what I don't like is the implied nested looping (I assume the join has to be re-done for each iteration through @l1?). Plus, the join just seems kind of ugly. Maybe it's unavoidable. For the record, this is for Text::CSV::Simple and I am trying to make a field map. _________________________________________________________________________________ I like computer programming because it's like Legos for the mind.
Back to
Seekers of Perl Wisdom
|
|