$ perl -we'sub makeit { my $i; sub { ++$i; ($i%6==1)..($i%6==3) } } $z = makeit(); $y = makeit(); print grep {&$y; &$z} "a".."r"' abcghimno