#!/usr/bin/perl $cmd1 = 'This'; $cmd2 = 'Is'; $cmd3 = 'a'; $cmd4 = 'test'; my @cmds = (1..4); for (@cmds){ print ${"cmd$_"},$/; }