#!/usr/bin/perl print "enter the START number: \n"; $number1 = ; print "enter END number: \n"; $number2 = ; @list=($number1..$number2); print "@list\n"; # if the file already exists. open OUTFILE, ">>/path/to/outfile" or die "Cannot open $!\n"; # if you want to create new file each time the program is executed. # open OUTFILE, ">/path/to/outfile" or die "Cannot open $!\n"; map { print OUTFILE $_, "\n"; } @list; close (OUTFILE);