my @cat=(1,2,3); my @dog=(5,6); my @pig=(4,3,2,1); my %animals; $animals{'cat'}=\@cat; $animals{'dog'}=\@dog; $animals{'pig'}=\@pig; for('cat','dog','pig'){ # we want the specific order ${$animals{$_}}[1]=$_; #stuff(@{$animals{$_}}) } say @cat;