my ($i); for ($i = 0; ($i < int (@commandsProperOrder)); $i += 2) { $commandsProperOrder{$commandsProperOrder[$i]}= $commandsProperOrder[$i + 1]; }