use warnings; use strict; use List::MoreUtils qw(firstidx); my @fsg = (1, 2, 4, 5, qw(A B C)); printf "item with index %i in list is B\n", firstidx { $_ eq 'B' } @fsg; printf "item with index %i in list is 2\n", firstidx { $_ eq 2 } @fsg; __END__ item with index 5 in list is B item with index 1 in list is 2