#!/usr/bin/perl -wl use strict; sub in { my $h = pop; @_ && ($h eq pop or in(@_, $h)) } my @a = qw(a b c d e f g h); print in(@a, $_) . " for $_ in (@a)" for qw(a c f v d s);