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;