I'm only a Perl beginner and I know there are lots and lots of pages out there that deal with searching through arrays, but I cannot find anything relevant to my problem.
I have two arrays and I want to find if one of the arrays is contained within the other (with the order preserved). Moreover I want to then be able to delete the contents of one array from the other
@bigarray qw(this is the main array from which to delete elements) @smallarray qw(delete elements)An array such as @other qw(elements delete) should not match against @bigarray.
I need to somehow remove "delete elements" from @bigarray. I have tried using nested loops, trying to keep track of indexs so I can use splice, but I just can't figure out how to do it properly with loops
@bigarray will probably be <1K in size and this delete action will only be called perhaps once or twice during my script, so efficiency is not an issue.
Any help appreciated :-)
Just for clarity, the exact sequence from @smallarray should be removed from @bigarray i.e.
@bigarray qw(delete this is elements the main array from which to delete elements)should be transformed to
@bigarray qw(delete this is elements the main array from which to)Thanks!
In reply to Check if one array is a subset of another by cstrong
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |