my @folder = qw( a b c d e f ); my @name = qw( x y z ); my $var = $folder[@name]; # $var = 'd', since @name == 3.