Remove an array from another array in perl

https://stackoverflow.com/questions/30889482/remove-elements-in-one-array-from-another-array-in-perl

 

To filter an array, you can use grep:

my @nonlinks = grep { my $f = $_;
                      ! grep $_ eq $f, @symbolic_files_found }
               @files_found;

But it's usually cleaner to use a hash.

my %files;
@files{ @files_found } = ();            # All files are the keys.
delete @files{ @symbolic_files_found }; # Remove the links.
my @nonlinks = keys %files;
posted on 2018-12-12 19:59  guolongnv  阅读(132)  评论(0)    收藏  举报