in reply to Re: Find array duplicates
in thread Find array duplicates
How about this?
Of course, you probably don't want to hard code the list of excluded tables in the subroutine (I don't know though, you might). And I'm not sure why you want a prototype on this subroutine either.sub checkxtlist (@) { my @Excluded = qw(Table_A Table_B); my %Excludes = map { $_ => 1 } @Excluded; my @Accepted = grep { !$Excludes{$_} } @_; my $status = (@_ == @Accepted) ? "good" : "bad"; }
Also, if you wanted to exclude by regular expression, you could do that too without much difficulty:
sub checkxtpatlist ($@) { my $pat = shift; my @Accepted = grep { !/$pat/ } @_; return my $status = (@_ == @Accepted) ? "good" : "bad"; } my $s = checkxtpatlist(qr/Table_[ABC]/,@tables);
|
|---|