sub create_list { my @skip_dbs = @_; # declare the hash my %skippables; # populate the hash with the skippables $skippables{$_}++ for @skip_dbs; my @dbs = qw/fetch forward user smtp/; # return a list of each element of @dbs # that isn't in the skippables hash return grep { ! $skippables{$_} } @dbs; } my @list = create_list("user", "smtp"); print "@list";