'Ello, I'm Andrew & I have a very big problem. I'm learning Perl & I'm having problem with my first simple code. Every time I go to look @ the page it just comes up excluding the HTML tags. Here's the code 'firstscript.cgi':

#! /usr/bin/perl
print  "Content-type:text/html\n\n";

print  "<html><head><title>My First Script</title></head>\n\n";
print  "<body>\n";
print  "<p>Hello world!</p>\n";
print  "</body></html>";

& it's URL
I think it's
1) My Firefox Browser
2) The fact that I don't see the path to the shebang statement anywhere

If you are running the script as a CGI from a browser of course you will not see the html tags. You will see them in the source code,

I'm going to go out on a limb and ask: are you viewing your page by just loading it into your browser?

Do you realize that with CGI scripts you have to access them through a web server? You would have to point your browser to '127.0.0.1/cgi-bin/your_script.pl' or wherever you have your web server configured to hold executables.

Do you have a web server running? This may seem like an obvious question, but if this is your first CGI script perhaps you may have missed that bit of crucial information.

Also please answer for us:

What OS are you running? Even though the shebang line indicates some flavour of Linux or UNIX, it doesn't matter in a Windows environment.

What exactly do you see when you view the page? I'm sorry but I won't be visiting the URL you posted.

If you see "Hello world!" in the browser when you pull up this page, then it's working fine. This isn't so much of a cgi script as a perl script that prints out html.

You won't see the #! perl line or any of the print statements. When you view source, you'll just see what you've printed.

I think you've got it right, just, maybe, unclear on what you're looking for

Best wishes,

, Mike

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.