my $target_word; for (my $i = 0; $i < @arglist; ++$i) { $target_word = $arglist[$i+1], last if $arglist[$i] eq "-iL"; }