my @out = qw(one two three four five six seven eight nine); my $i = 0; foreach (@out) { print "\$out[",$i++,"] = '$_'\n"; } =output= $out[0] = 'one' $out[1] = 'two' $out[2] = 'three' $out[3] = 'four' $out[4] = 'five' $out[5] = 'six' $out[6] = 'seven' $out[7] = 'eight' $out[8] = 'nine'