new to perl

T

Tsui Wai-ming

I just started to learn CGI by writing a perl script, but what appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.

This is the script I wrote, in fact it is what I directly copied from "Perl
How to Program":

#!c:\perl\bin
#displaying time in brower

print "Content-type: text/html\n\n";
print "<html><head><title>Hello!</title>";
print "</head>\n<body>";
print scalar( localtime() );
print "</body></html>"

Many thanks!!!
 
K

Keith Keller

-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

I just started to learn CGI by writing a perl script, but what appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.

Your webserver is not configured properly. Find out how to
configure it (in a different newsgroup, most likely).

- --keith

- --
(e-mail address removed)-francisco.ca.us
(try just my userid to email me)
AOLSFAQ=http://wombat.san-francisco.ca.us/cgi-bin/fom

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.2.3 (GNU/Linux)

iD8DBQFARgcUhVcNCxZ5ID8RAk7CAJ9F2Ljdu28kVDyHguGTGXcIuDGw3QCfeRX+
Qaxm58GtipvXm2x+6UBgLSk=
=wCQu
-----END PGP SIGNATURE-----
 
R

Regent

Tsui said:
I just started to learn CGI by writing a perl script, but what appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.

This is the script I wrote, in fact it is what I directly copied from "Perl
How to Program":

#!c:\perl\bin
#displaying time in brower

print "Content-type: text/html\n\n";
print "<html><head><title>Hello!</title>";
print "</head>\n<body>";
print scalar( localtime() );
print "</body></html>"

Many thanks!!!
Why not tell us WHAT is on the browser.

Regent
 
R

Regent

Tsui said:
I just started to learn CGI by writing a perl script, but what appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.

This is the script I wrote, in fact it is what I directly copied from "Perl
How to Program":

#!c:\perl\bin
#displaying time in brower

print "Content-type: text/html\n\n";
print "<html><head><title>Hello!</title>";
print "</head>\n<body>";
print scalar( localtime() );
print "</body></html>"

Many thanks!!!
Well, I believe your shebang line should be

#!c:\perl\bin\perl

Regent
 
T

Tore Aursand

I just started to learn CGI by writing a perl script, but what appeared
on the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.

This has nothing to do with Perl, but how your web-server is configured.
It seems to be that it isn't set up to handle your Perl-scripts the right
way.

Please ask your question in a newsgroup related to which web-server you
are using, or in a CGI-related newsgroup.
 
G

gnari

Tsui Wai-ming said:
I just started to learn CGI by writing a perl script, but what appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.
[snip perl program]

are you using a web server?

gnari
 
T

Tony Muler

Regent said:
Well, I believe your shebang line should be

#!c:\perl\bin\perl

And I believe the shebang is not necessary at all
on Windows. Right?

T.
 
T

Tony Muler

Regent said:
Tsui said:
I just started to learn CGI by writing a perl script, but what
appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.
[...]

Why not tell us WHAT is on the browser.

He said it: Exactly what was typed into the editor.
This means that the file is treated as a normal
text file by the webserver, not as a CGI script.
It was not executed but just displayed.

But as others have said already: This is more
a comp.infosystems.www.servers.ms-windows
or s.th. like that.

T.
 
B

Ben Morrow

Regent said:

Err... because Windows doesn't follow the #! convention? It does have a use,
however: perl will read switches from the #! line if it is there. This can
be the only way to specify -T.

Ben
 
R

Regent

Ben said:
Err... because Windows doesn't follow the #! convention? It does have a use,
however: perl will read switches from the #! line if it is there. This can
be the only way to specify -T.

Ben
Oh really. Does this mean the shebang can be omitted, if no switch is
used? I've programmed Perl on Windows for a few years but never thought
about this :-(

Regent
 
R

Regent

Ben said:
Err... because Windows doesn't follow the #! convention? It does have a use,
however: perl will read switches from the #! line if it is there. This can
be the only way to specify -T.

Ben
Eh, I'm programming Perl cgi with Apache, so the shebang is necessary.

Regent
 
B

Ben Morrow

Scott Bryce said:
I believe the correct answer is, It depends.

If your system is configured to look up the .pl extension in the system
registry and determine from that to use the perl interpreter to run the
script, then the shebang can be left out. Otherwise, you need to leave
it in.

No, it will make no difference. Windows *never* looks for a #! line, so
it doesn't matter if it's there or not. Apache may be a different
matter, of course.

Ben
 
T

Tsui Wai-ming

Thanks everybody! I changed a line in httpd.conf and now i'm able to learn
CGI!
The line is the one starts with "scripalias".
And i've learnt a lot from all the replies too!

Ming~
 
T

Tsui Wai-ming

In fact I just changed to

#!C:\perl\bin\perl

This one
# perl, and
#!C:\perl\bin

didnt work at all...
 
G

gnari

Tony Muler said:
Regent said:
Tsui said:
I just started to learn CGI by writing a perl script, but what
appeared on
the browser was exactly what I'd typed in the editor, minus the
<title>xxx</title> line.
[...]

Why not tell us WHAT is on the browser.

He said it: Exactly what was typed into the editor.
This means that the file is treated as a normal
text file by the webserver, not as a CGI script.
It was not executed but just displayed.

what's the bit with the 'minus the <title>xxx</title> line' then ?

gnari
 
J

Joe Smith

Tsui said:
In fact I just changed to

#!C:\perl\bin\perl

This one
# perl, and
#!C:\perl\bin

didnt work at all...

It depends on how you invoke your perl script.

Double-clicking on an icon in a local file folder: Uses registry.
Typing name into CMD.EXE command-line prompt: Uses registry.
Typing name into some other command-line shell: Depends on shell (bash).
(In particular, cygwin uses /usr/bin/perl.)
Clicking on link in a browser: Depends on web server.
Sambar Server for Windows: Uses shebang line.
Apache Server for Windows: I believe it is a configuration option.
IIS: Registry.

Which method "didnt work at all"?
-Joe
 
C

Chris

Scott said:
I believe the correct answer is, It depends.

If your system is configured to look up the .pl extension in the system
registry and determine from that to use the perl interpreter to run the
script, then the shebang can be left out. Otherwise, you need to leave
it in.

I don't believe this correct, not that it matters a tremendous deal.
Under Windump If there is no association with .pl to run perl.exe, then
Windump doesn't know WHAT to do with it and it punts. You would have to
preface your script with 'perl' to get it to run in which case you could
just as easily name it .txt and it would still work:

C:\> script.pl
'script.pl' is not recognized as an internal or external command,
operatable program or batch file.

C:\> type script.pl
print "This is all there is in here!\n";

C:\> perl script.pl
This is all there is in here!

C:\> copy script.pl script.txt
C:\> perl script.txt
This is all there is in here!

C:\> assoc .pl=Perl
C:\> ftype Perl=c:\perl\bin\perl.exe %1 %*
C:\> script.pl
This is all there is in here!


I think any way you cut it, the she-bang is not required in Windump
unless you want to pass a switch like -w or -T.

None of this will help the OP, but maybe is worth something.

chris
 
C

Chris

Joe said:
It depends on how you invoke your perl script.

Double-clicking on an icon in a local file folder: Uses registry.
Typing name into CMD.EXE command-line prompt: Uses registry.
Typing name into some other command-line shell: Depends on shell (bash).
(In particular, cygwin uses /usr/bin/perl.)
Clicking on link in a browser: Depends on web server.
Absolutely.

Sambar Server for Windows: Uses shebang line.
Apache Server for Windows: I believe it is a configuration option.
IIS: Registry.

Nope. IIS needs an association set in it's configuration to get .pl
files to work as CGI. And the directory the .pl scripts are in has to
be set to "Scripts and Executables" ('Scripts' meaning .asp pages, not
CGI). And all IIS settings get stored in the IIS meta-base (separate,
very hokied up file), not the registry up through IIS v5.1. IIS 6.0
uses an XML meta-base. The registry is not used (as far as I know up
through v5.1).

Chris
 
T

Tsui Wai-ming

Joe Smith said:
It depends on how you invoke your perl script.

Double-clicking on an icon in a local file folder: Uses registry.
Typing name into CMD.EXE command-line prompt: Uses registry.
Typing name into some other command-line shell: Depends on shell (bash).
(In particular, cygwin uses /usr/bin/perl.)
Clicking on link in a browser: Depends on web server.
Sambar Server for Windows: Uses shebang line.
Apache Server for Windows: I believe it is a configuration option.
IIS: Registry.

Which method "didnt work at all"?
-Joe

This one: #perl
And this one: #!C:\perl\bin

Ming :)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,146
Messages
2,570,832
Members
47,374
Latest member
EmeliaBryc

Latest Threads

Top