Spencer, Thanks for the reply, but this did not worked. It is prompting for the files to be opened or saved as it happens at the time of downloading something. If I click the open, it opens the file in the notepad and not in the browser.
Thanks Bal. -----Original Message----- From: Spencer Christensen [mailto:[EMAIL PROTECTED]] Sent: Monday, March 04, 2002 1:11 PM To: [EMAIL PROTECTED] Subject: Re: [cgiapp] Printing in plain text format. Quoting "Sabherwal, Balvinder (MBS)" <[EMAIL PROTECTED]>: > Guru's > > I have the following code in my script. I want to print the output in > plain > ASCII text. If I use blockquote() it prints in the RTF format and I lose > all > the space formatting. Is there any way I can change this to print in > plain > ASCII text?? > > TIA. > Bal. > > sub showdetails { > my $self = shift; > #Get CGI query object > my $q = $self->query(); > my $app = $q->param("app"); > my $tdir =$q->param("tdir"); > my $yrs =$q->param("yrs"); > my $dts =$q->param("dts"); > my $rep = $tdir. "\\\\" . $app . "\\\\" . $yrs . "\\\\" . $dts; > my $output = ''; > $output .= $q->start_html(); > $output .= $q->header('text/plain'); > open(FH, $rep ); > while (<FH>){ > chomp; > $output .= $q->blockquote("$_"); > } > $output .= $q->end_html(); > close(FH); > return $output; > } Hello Bal, If you want to display the entire page as text/plain, then there are a few things you should change. First of all, you should add error checking to your open statement (this is just good programming practice). Second, you try to set the header for the page by $q->header('text/plain'), but this won't work. Instead you should set it by $self->header_props(-type=>'text/plain'). And third, if you want the whole page to be plain text, don't start and end the page with HTML (this will just show up as extra text). Here is my version of your code: sub showdetails { my $self = shift; #Get CGI query object my $q = $self->query(); my $app = $q->param("app") || ''; my $tdir =$q->param("tdir") || ''; my $yrs =$q->param("yrs") || ''; my $dts =$q->param("dts") || ''; my $rep = $tdir. "\\\\" . $app . "\\\\" . $yrs . "\\\\" . $dts; open(FH, $rep) or return "Cannot open $ref: $!"; # Error checking my $output = join('', <FH>); # Put entire file into one string close(FH); $self->header_props(-type => 'text/plain'); # Set page as plain text return $output; } -spencer christensen [EMAIL PROTECTED] --------------------------------------------------------------------- Web Archive: http://www.mail-archive.com/[email protected]/ To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
