TIMTOWTDI, but I think that:
foreach my $item (@list) { next if !$seen && ($item ne 'valueC'); $seen++; ... }
It is quite readable, correct and concise. Everything / valueC / solution will handle anything after "DooDadvalueCFuBAr", not what the OP sets. And you donβt need a flipflop / range operator, and checking for the presence is actually really strange, in addition, requiring a possibly incompatible package to perform a rather trivial task. The grep solution really makes me spin my head, besides creating and throwing up the tempo of the array as a side effect.
If you want some fantasy and avoid "ifs":
foreach my $item (@list) { $seen || ($item eq 'valueC') || next; $seen++; ... }
Just don't write home about it. :-)
source share