On Mon, Feb 9, 2009 at 18:39, itshardtogetone <itshardtogetone@hotmail.com> wrote: > Hi, > Looking at the script below, I wish to print out "line 1" first, which is after the while loop, then followed by "First loop", and then "Second loop", henceforth I have the script below. What I did was to hold on the printing of "First loop" and "Second loop" by pushing them into @printer which was then printed out after printing "line1. > > The problem is, if there are many iterations of the while loops, then the contents of @printer becomes very large before its printed out and this I fear may take up a lot of memory. I then wonder are there any other better ways for me to do this. > Thanks > > #### scripts ####### > #!/usr/bin/perl > use warnings; > > while ( 1 ){ > push @printer,"First loop\n"; > while ( 1 ){ > push @printer,"Second loop\n"; > last; > } > last, > } > > print "line 1\n"; > print @printer; > It seems odd to me that you wish to delay printing of sequential lines. What benefit do you seek by doing so? If you absolutely must avoid outputting data until after the loops are finished, you should probably write your output to a file and then display the file after the loop. -- Chas. Owens wonkden.net The most important skill a programmer can have is the ability to read.Thread Previous | Thread Next