my $input = $ARGV[0] || 'bar'; my @repo = qw (foo bar qux); map{ print $_ if $repo[$_] eq $input } 0..$#repo;