use List::Util qw( first ); for my $current (@genes) { say $current if first { $_ eq $current } @gl; }