W
wana
Suppose I want to create an array made up of all of the elements of @a
except for those that are also contained in @b. For example:
(apple, banana, peach, pear) - (apple, peach) = (banana, pear)
I was hoping that @c = @a - @b; would work. This would really be
making an easy task easy.
Searching the faqs and docs, the solution seems to be a confusing (to
me at least) use of either a hash or grep. I looked at the map
function which seemed appropriate, but I couldn't think of an obvious
way to do it.
I finally settled for the old C way of doing it of having a loop in a
loop to compare each value of one array against each value of the
other.
Is there a better way? Would it be wrong for Perl to make @a-@b
legal?
except for those that are also contained in @b. For example:
(apple, banana, peach, pear) - (apple, peach) = (banana, pear)
I was hoping that @c = @a - @b; would work. This would really be
making an easy task easy.
Searching the faqs and docs, the solution seems to be a confusing (to
me at least) use of either a hash or grep. I looked at the map
function which seemed appropriate, but I couldn't think of an obvious
way to do it.
I finally settled for the old C way of doing it of having a loop in a
loop to compare each value of one array against each value of the
other.
Is there a better way? Would it be wrong for Perl to make @a-@b
legal?