use strict; use warnings; # array choices my %arrays = ( ab => [ "one", "two", "three" ], cd => [ "four", "five", "six" ], ef => [ "seven", "eight", "nine" ], ); my $sel = join '', @ARGV[0..1]; # Print contents of the chosen array foreach my $item (@{$arrays{$sel}}) { print "$item\n"; }