Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: print file in cgi with perl

by dga (Hermit)
on Jul 23, 2003 at 16:02 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://277227]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (4)
As of 2024-04-19 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found