Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

printing to web browser

0 views
Skip to first unread message

daniel kaplan

unread,
Oct 21, 2004, 5:43:39 PM10/21/04
to
still new to PERL, anyway write now i do all OUTPUTTING to the web browser
with:

print $q->header();
print $out;

but what i would really likee to do is print everything out in TEXT only
format...for debuggin purposes....

is there a way to do this, so the browser does NOT print using HTML
formating, and just prints everything in plain text?

thanks!


Gunnar Hjalmarsson

unread,
Oct 21, 2004, 5:55:03 PM10/21/04
to
daniel kaplan wrote:
> still new to PERL, anyway write now i do all OUTPUTTING to the web
> browser with:
>
> print $q->header();
> print $out;
>
> but what i would really likee to do is print everything out in TEXT
> only format...for debuggin purposes....

If you are using a standards compliant browser, you can just do:

print "Content-type: text/plain\n\n";

However, I see that you are posting from Outlook, and if that means that
you are browsing the web with MSIE, using the <pre> tag may be an
alternative. But then you also need to

s/</&lt;/g;
s/>/&gt;/g;

before printing to STDOUT.

--
Gunnar Hjalmarsson
Email: http://www.gunnar.cc/cgi-bin/contact.pl

Alan J. Flavell

unread,
Oct 21, 2004, 5:58:51 PM10/21/04
to
On Thu, 21 Oct 2004, daniel kaplan wrote:

> but what i would really likee to do is print everything out in TEXT only
> format...for debuggin purposes....

The Perl language doesn't care in the least whether you print
a content-type header of text/html or text/plain

> is there a way to do this,

Sure

> so the browser

That depends a bit on what you mean by "the browser". There are
browsers which are compatible with the applicable IETF and W3C
specifications in this regard, and then there's a disreputable
operating system component that occasionally gives an impression of
being a WWW browser, but (it seems) more by accident that by design.
None of this is Perl-specific, though. Have you considered using the
newsgroup recommended in perlfaq9? (but beware the automoderation
bot).

daniel kaplan

unread,
Oct 21, 2004, 6:19:38 PM10/21/04
to
> print "Content-type: text/plain\n\n";

you mean start my $out with the above?


Jim Gibson

unread,
Oct 21, 2004, 6:24:05 PM10/21/04
to
In article <10983950...@nntp.acecape.com>, daniel kaplan
<nos...@nospam.com> wrote:

> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
> with:

Experienced Perl programmers don't use all CAPS.

>
> print $q->header();
> print $out;
>
> but what i would really likee to do is print everything out in TEXT only
> format...for debuggin purposes....
>
> is there a way to do this, so the browser does NOT print using HTML
> formating, and just prints everything in plain text?

Print stuff between <pre> and </pre> tags. You can also use the
$q->pre() function of CGI, which, since it is not documented in perldoc
CGI, is probably an auto-generated tag function.

daniel kaplan

unread,
Oct 21, 2004, 7:09:01 PM10/21/04
to
see am using Net::Pop3 to read emails...and i have to disect the text, so
need to see it all to make the program...and when i print it out in the
browser, the HTML kicks in, and i don't see all the "actual text"

please help


Scott Bryce

unread,
Oct 21, 2004, 7:55:07 PM10/21/04
to
daniel kaplan wrote:

Then send the output to a file as well as the browser. Or use
View|Source to see what the browser is getting.

Gunnar Hjalmarsson

unread,
Oct 21, 2004, 8:53:56 PM10/21/04
to
daniel kaplan wrote:
>> print "Content-type: text/plain\n\n";
>
> you mean start my $out with the above?

I mean that you can replace

print $q->header();

with that.

Tintin

unread,
Oct 22, 2004, 2:00:38 AM10/22/04
to

"Gunnar Hjalmarsson" <nor...@gunnar.cc> wrote in message
news:2tr42qF...@uni-berlin.de...

> daniel kaplan wrote:
>>> print "Content-type: text/plain\n\n";
>>
>> you mean start my $out with the above?
>
> I mean that you can replace
>
> print $q->header();
>
> with that.

Seeing as he's using the CGI module, he might as well use:

print $q->header('text/plain');


Paul Robson

unread,
Oct 22, 2004, 2:12:10 AM10/22/04
to
On Thu, 21 Oct 2004 15:24:05 -0700, Jim Gibson wrote:

> In article <10983950...@nntp.acecape.com>, daniel kaplan
> <nos...@nospam.com> wrote:
>
>> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
>> with:
>
> Experienced Perl programmers don't use all CAPS.

Does <stdin> work then ?

Alan J. Flavell

unread,
Oct 22, 2004, 3:24:17 AM10/22/04
to
On Thu, 21 Oct 2004, Jim Gibson wrote:

> Print stuff between <pre> and </pre> tags.

Merely clamping material in a <pre> element does not, in general,
turn it into plain text. You'd need to escape the HTML-significant
characters in it (escapeHTML() in CGI.pm) too.

If you've no other reason for sending content-type text/html then I'd
still say that sending text/plain is the straightforward solution.

This of course has nothing directly to do with Perl. It would be the
same principle in any scripting language.

Tad McClellan

unread,
Oct 22, 2004, 7:15:30 AM10/22/04
to


What happened when you tried it? (yes, it does work)


Experienced Perl programmers don't spell it "PERL", because
it is not an acronym.

If you call it PERL then you do not know the secret handshake.


--
Tad McClellan SGML consulting
ta...@augustmail.com Perl programming
Fort Worth, Texas

Chris Cole

unread,
Oct 22, 2004, 9:37:48 AM10/22/04
to
On Fri, 22 Oct 2004 06:15:30 -0500, Tad McClellan wrote:

> Paul Robson <auti...@autismuk.freeserve.co.uk> wrote:
>> On Thu, 21 Oct 2004 15:24:05 -0700, Jim Gibson wrote:
>>
>>> In article <10983950...@nntp.acecape.com>, daniel kaplan
>>> <nos...@nospam.com> wrote:

<snip>


>
> Experienced Perl programmers don't spell it "PERL", because
> it is not an acronym.

I beg to differ ;-)
From the Perl manpage:

NAME
perl - Practical Extraction and Report Language


Chris.

Alan J. Flavell

unread,
Oct 22, 2004, 9:39:10 AM10/22/04
to
On Fri, 22 Oct 2004, Tad McClellan wrote:

> If you call it PERL then you do not know the secret handshake.

The Perl FAQ is surely only a "secret" to those who treat this
group as a write-only medium.

Tad McClellan

unread,
Oct 22, 2004, 10:10:14 AM10/22/04
to
Chris Cole <ithi...@gmail.com> wrote:
> On Fri, 22 Oct 2004 06:15:30 -0500, Tad McClellan wrote:

>> Experienced Perl programmers don't spell it "PERL", because
>> it is not an acronym.
>
> I beg to differ ;-)


You know better than the Perl FAQ?


What's the difference between "perl" and "Perl"?

One bit. Oh, you weren't talking ASCII? :-) Larry now uses "Perl" to
signify the language proper and "perl" the implementation of it,
i.e. the current interpreter. Hence Tom's quip that "Nothing but perl
can parse Perl." You may or may not choose to follow this usage. For
example, parallelism means "awk and perl" and "Python and Perl" look
OK, while "awk and Perl" and "Python and perl" do not. But never
write "PERL", because perl is not an acronym, apocryphal
folklore and post-facto expansions notwithstanding.


> From the Perl manpage:
>
> NAME
> perl - Practical Extraction and Report Language


If it was an acronym it would have been spelled in ALL CAPS.

It appears that you have helped to prove my point. Thanks!

It is not an acronym, it is what might be called a "backronym"
since the word came first and the expansion of the letters in
the word came later.

krakle

unread,
Oct 22, 2004, 11:43:31 AM10/22/04
to
Jim Gibson <jgi...@mail.arc.nasa.gov> wrote in message news:<211020041524059555%jgi...@mail.arc.nasa.gov>...

> In article <10983950...@nntp.acecape.com>, daniel kaplan
> <nos...@nospam.com> wrote:
>
> > still new to PERL, anyway write now i do all OUTPUTTING to the web browser
> > with:
>
> Experienced Perl programmers don't use all CAPS.

Then why did you use CAPS?

John W. Kennedy

unread,
Oct 22, 2004, 3:04:24 PM10/22/04
to
Tad McClellan wrote:
> If it was an acronym it would have been spelled in ALL CAPS.

Actually, in the context of a man page, no, it wouldn't, because the
executable program is named "perl", not "PERL" or "Perl".

--
John W. Kennedy
"The pathetic hope that the White House will turn a Caligula into a
Marcus Aurelius is as naïve as the fear that ultimate power inevitably
corrupts."
-- James D. Barber (1930-2004).

Ben Morrow

unread,
Oct 22, 2004, 4:03:38 PM10/22/04
to

Quoth Chris Cole <ithi...@gmail.com>:

Just 'cos the docs contradict themselves doesn't make them wrong :)
(perlfaq1 states explicitly that Perl is not an acronym).

This backronym for Perl is something of a joke, as is 'Pathologicaly
Eclectic Rubbish Lister'. See the Camel for the actual history of the
name.

Ben

--
And if you wanna make sense / Whatcha looking at me for? (Fiona Apple)
* b...@morrow.me.uk *

John W. Kennedy

unread,
Oct 22, 2004, 6:08:35 PM10/22/04
to
Ben Morrow wrote:
> Just 'cos the docs contradict themselves doesn't make them wrong :)

...as Gödel's Theorem vanishes up its own nose....

--
John W. Kennedy
"Sweet, was Christ crucified to create this chat?"
-- Charles Williams. "Judgement at Chelmsford"

Jon Ericson

unread,
Oct 22, 2004, 7:02:16 PM10/22/04
to
kra...@visto.com (krakle) writes:

Sigh. Because it's shorter than Capitalization Annoying to Perl
Scripters.

Jon

P.S. I sense a "script versus program" flamewar coming on.

Aaron Sherman

unread,
Oct 22, 2004, 9:24:44 PM10/22/04
to
"daniel kaplan" <nos...@nospam.com> wrote in message news:<10983950...@nntp.acecape.com>...

> still new to PERL, anyway write now i do all OUTPUTTING to the web browser
> with:
>
> print $q->header();
> print $out;
[...]

> is there a way to do this, so the browser does NOT print using HTML
> formating, and just prints everything in plain text?

Yep, try:

use CGI qw(escapeHTML);
my $cgi = new CGI;
print $cgi->header();
print $cgi->start_html("Plain text output");
print $cgi->pre(escapeHTML($out));
print $cgi->end_html();
exit 0;

Laura

unread,
Oct 23, 2004, 9:32:07 AM10/23/04
to
Jon Ericson wrote:

>
> P.S. I sense a "script versus program[..]

A script is interpreted and a program is compiled. I know you can in Perl
and some other scripting languages turn a script into a program, which
makes it more like a real programming language, like C++ or Java. Perl is
a scripting tool written in C so C programmers can have the conveniences of
languages like C++ or Visual Basic without having to leave their native
environment.

lwt

Uri Guttman

unread,
Oct 23, 2004, 9:46:22 AM10/23/04
to
>>>>> "L" == Laura <lwt...@bellsouth.net> writes:

L> A script is interpreted and a program is compiled. I know you can
L> in Perl and some other scripting languages turn a script into a
L> program, which makes it more like a real programming language, like
L> C++ or Java. Perl is a scripting tool written in C so C
L> programmers can have the conveniences of languages like C++ or
L> Visual Basic without having to leave their native environment.

nonsense. balderdash. gobbledygook.

pick one.

uri

--
Uri Guttman ------ u...@stemsystems.com -------- http://www.stemsystems.com
--Perl Consulting, Stem Development, Systems Architecture, Design and Coding-
Search or Offer Perl Jobs ---------------------------- http://jobs.perl.org

Tad McClellan

unread,
Oct 23, 2004, 12:04:52 PM10/23/04
to
Laura <lwt...@bellsouth.net> wrote:
> Jon Ericson wrote:
>
>>
>> P.S. I sense a "script versus program[..]
>
> A script is interpreted and a program is compiled.


Perl is both compiled *and* interpreted (see perlrun.pod).

So which one is it if written using Perl?


[ That is a rhetorical question, as there is no correct answer.
The script vs. program thing has been discussed here ad nauseum
and is always valueless as there is no difference.
I think Jon was being sarcastic, yet here you are, starting
up such a useless subthread yet again...
]


> I know you can in Perl
> and some other scripting languages turn a script into a program, which
> makes it more like a real programming language, like C++ or Java.


That is a load of hooey.

If you can write "programs" in it, then it is a real "programming language".


> Perl is
> a scripting tool written in C so C programmers can have the conveniences of
> languages like C++ or Visual Basic without having to leave their native
> environment.


Yet more foolishness!

daniel kaplan

unread,
Oct 23, 2004, 12:22:10 PM10/23/04
to
>If you can write "programs" in it, then it is a real "programming
language".

that is the bottom line, whether it is compiled at run time or before only
counts as a difference in speed. but the bottom line is that it IS a
programming language...


Anno Siegel

unread,
Nov 1, 2004, 5:42:06 AM11/1/04
to
Uri Guttman <u...@stemsystems.com> wrote in comp.lang.perl.misc:

> >>>>> "L" == Laura <lwt...@bellsouth.net> writes:
>
> L> A script is interpreted and a program is compiled. I know you can
> L> in Perl and some other scripting languages turn a script into a
> L> program, which makes it more like a real programming language, like
> L> C++ or Java. Perl is a scripting tool written in C so C
> L> programmers can have the conveniences of languages like C++ or
> L> Visual Basic without having to leave their native environment.
>
> nonsense. balderdash. gobbledygook.
>
> pick one.

Why? They all apply.

Anno

0 new messages