$ perl -MList::Util=first -E 'my @x = qw{1 0 0 1 2 0 1 0 3 0 1 1 4 1 0 0}; say first { $x[$_] == 2 } 0 .. $#x' 4