my $index = 0; my $input = $ARGV[0] || 'bar'; my @repo = qw (foo bar qux); $index++ until @repo[$index] eq $input or $index > $#repo; #don't want to loop forever if it's not found