generating number sequence in Perl or PHP

How do I create a file with a million(-1) of lines like these in Perl or PHP?

pippo000001
pippo000002
pippo000003
pippo000004
pippo000005
pippo000006
pippo000007
pippo000008
pippo000009
pippo000010
pippo000011
pippo000012
pippo000013

...
pippo999999
lucavillaAsked:
Who is Participating?
 
ozoConnect With a Mentor Commented:
perl -le "print for pippo000001 .. pippo999999" > file
0
 
morristhebearConnect With a Mentor Commented:
This should do it.  Obviously change the file name.  This places each pippoxxx on a newline.

<?php
 
	if ($file = fopen ("C:\\file2.txt", "w")) {
		for ($i = 0; $i < 100000; $i++) {
			fwrite ($file, 'pippo' . str_pad($i, 6, '0', STR_PAD_LEFT) . PHP_EOL);
		}
	}
	
?>

Open in new window

0
 
morristhebearCommented:
Oh, silly me.  Change the 100000 to 1000000.  I used 100000 for testing.
0
 
lucavillaAuthor Commented:
Wow, I love the simplicity of Perl! :)
0
 
lucavillaAuthor Commented:
I posted a new similar question here: http://www.experts-exchange.com/Web_Development/Web_Languages-Standards/PHP/Q_23512022.html

Thanks again for your help!
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.