my $file_name = 'file'; print "Enter the number in the first batch file:\n"; $f=; print "Enter the number in the last batch file:\n"; $l=; for( $f..$l ){ my $file="$file_name$_.bat"; system($file) == 0 or die $?; sleep(2); }