##
{
# For the sake of the example, this assumes that you
# want to limit the possible input to this range
print "Please enter a number [1-9999]: ";
chomp($in = );
redo unless $in =~ /^\d+$/ && $in > 0 && $in <= 9999;
}
print join(",", 1 .. $in), "\n";
## ##
print $in--; do { print ", $a" } while --$a;
for ($i=1;$i <= $in; $i++){ print $i-1?",$i":$i; }
while($in){push @a, $in--;} print join ",", reverse @a;