t-rex has asked for the wisdom of the Perl Monks concerning the following question:
I have two arrays
A1=0 1 2 3 4 5 6 7 A2=6 7
I have to remove elements 6 and 7 from A1 which are present in A2. Basically whatever elements are present in A2 should be removed from A1. How do i do it, one way was splice but i am getting different outputs not what I expect ?
Note : A1 is for me is an array of reference
foreach my $A1 (@cpu_lists) @A2 = @{$A1}[-n..-1]; #A2 is derived from A1 @{$A1} = splice @{$A1},6,-1;#A1 should be spliced to remove elements o +f A2 where n = number of elements which we want in A2.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: removing elements in array in Perl
by Athanasius (Archbishop) on Nov 23, 2016 at 09:21 UTC | |
Re: removing elements in array in perl
by Corion (Patriarch) on Nov 23, 2016 at 09:05 UTC | |
by t-rex (Scribe) on Nov 23, 2016 at 09:29 UTC | |
by Corion (Patriarch) on Nov 23, 2016 at 09:37 UTC | |
by AnomalousMonk (Archbishop) on Nov 23, 2016 at 16:42 UTC | |
by t-rex (Scribe) on Nov 23, 2016 at 09:50 UTC | |
Re: removing elements in array in perl
by Marshall (Canon) on Nov 23, 2016 at 17:12 UTC |