I m new to perl and i have to develop such webserice which can use the perl script via html so that the source of the perl file cannot be displayed only the output is displayed.

Recommended Answers

All 5 Replies

Do you mean you want the perl code embedded in the html code (sort of like php)?

Search google for: "embedded perl"

No Kani,
Actually I m working on a website which works as a webserver.I want that if we write a perl and call it through HTML then while we host this HTML page it is showing the source code of the perl and we don't want that.
I want tht when we code into perl in HTML then it will host the output of the perl.
Take an example suppose we are connecting a database in MySql through perl and hosting tht code through HTML then it should display the contents of the database or the query fired on the database not the source code of the perl.


Do you mean you want the perl code embedded in the html code (sort of like php)?

Search google for: "embedded perl"

Member Avatar for Dukane

Are you forgetting the "Content-type: text/html\n\n" line? If you do, the browser doesn't know that HTML is coming and displays the script source instead.

Also the server must know that when a browser calls a script with either the .pl or .cgi extension that it is to start the Perl interpreter and run the program and not just send the file back to the client.

No Kani,
Actually I m working on a website which works as a webserver.I want that if we write a perl and call it through HTML then while we host this HTML page it is showing the source code of the perl and we don't want that.
I want tht when we code into perl in HTML then it will host the output of the perl.
Take an example suppose we are connecting a database in MySql through perl and hosting tht code through HTML then it should display the contents of the database or the query fired on the database not the source code of the perl.

Obviously you first need perl installed on the server. Then the server has to be configured to execute scripts instead of just returning the text like it would with html documents.

But as far as "hosting the code through html" goes, are you trying to use SSI tags to run scripts? You can do that in pages that the server knows to parse fo SSI tags, normally .shtml or .shtm pages.

Are you forgetting the "Content-type: text/html\n\n" line? If you do, the browser doesn't know that HTML is coming and displays the script source instead.

if you forget that line with perl generated output to a browser you get an internal server error. But the server error log should show an error about incomplete/malformed header. The exact error message depends on the http server being used.

commented: The only person to keep the Perl Forum alive ;) - ~s.o.s~ +9
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.