use List::MoreUtils qw(firstidx); @input=('a','b','c','d'); my $char='b'; print firstidx { $_ eq $char } @input;