Beefy Boxes and Bandwidth Generously Provided by pair Networks
Do you know where your variables are?
 
PerlMonks  

Re: print file in cgi with perl

by dga (Hermit)
on Jul 23, 2003 at 16:02 UTC ( #277227=note: print w/replies, xml ) Need Help??


in reply to print file in cgi with perl

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.

Replies are listed 'Best First'.
Re: Re: print file in cgi with perl
by aroso (Novice) on Jul 23, 2003 at 17:07 UTC
    I use the apache 2.0.46 server for windows2000 and the IE5.
    The problem is that the browser dont print anything.
    But in the "view source" there are all i want.
    So, the problem can be the header type.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://277227]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (7)
As of 2021-06-14 22:24 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What does the "s" stand for in "perls"? (Whence perls)












    Results (66 votes). Check out past polls.

    Notices?