#!/usr/bin/perl -wl use strict; my @db = qw(aaa bbb ccc ddd eee fff); my @in = qw(aaa fff); my %h; # Initialise the hash using a slice @h{@in} = undef; print "@db"; @db = grep {not exists $h{$_}} @db; print "@db"; __END__ Prints: aaa bbb ccc ddd eee fff bbb ccc ddd eee