I've written the following code snippet to try and demonstrate my problem:
I need to compare the two arrays (one being an array of arrays), against another array, more specifically look at the second element of @array against the contents of @compare and eliminate the duplicates from @array.#!/perl/bin/perl.exe -w use strict; use vars qw(@array @data @compare $num ); $num = 0; for (0 .. 3) { @array = (); for (0 .. 1) { push @array, $num; $num ++; } push @data, [@array]; } @compare = (2, 4, 5, 6); print "Contents of \@array\n"; foreach my $record (@data) { for my $i (0 .. 1) { print $record->[$i] . " "; } print "\n"; } print "\n\nContents of \@compare\n"; foreach (@compare) { print $_, " "; }
I should end up with the following values for @array ...
Notice that the number 5 was the second element in @array Any ideas ?Contents of @array 0 1 2 3 6 7 Contents of @compare 2 4 5 6
In reply to Array element removal by The_Rev
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |