Your do is passed along to print as a list which takes the list, inserts a space between the items, and prints it out. Also since you are assiging a value to $i it is passed along to print to be printed also.
Additionally, you are loading the entire file into your programs memory space and then tossing all but the first 30 lines.
#starting from the open print header; print start_html('A Simple Example'); my $i=0; while(<INPUT>) { $i++; last if $i>30; print; } close(INPUT); print end_html;
I tried to make this example similar in spirit to the original. This method only reads the first 30 lines and only uses memory for one at a time. The file you are printing is not html though so it will still not look right at all in a browser. You may want:
print header('text/plain'); #the while here #no start or end html prints
This will print the contents as a text file in which the line breaks and spacing from the file will be preserved.
In reply to Re: print file in cgi with perl
by dga
in thread print file in cgi with perl
by aroso
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |