samhaintha has asked for the wisdom of the Perl Monks concerning the following question:

Hi - I hope this is th eright place to ask - I know that some web pages have javascript to make thame active... is there any way to use PERl to do the same thing? - Thanks alot - samhaintha

Replies are listed 'Best First'.
Re: PERL on web pages
by Joost (Canon) on Apr 17, 2003 at 14:25 UTC
    Hi samhaintha,

    If you really want the Perl as a client-side scripting language, you can use PerlScript, which is part of the Active Perl package from ActiveState.

    This will require every user to install ActivePerl though.

    If you are more interested in a server-side solution, you can take a look at the Network/CGI Programming section in the Tutorials.

    -- Joost downtime n. The period during which a system is error-free and immune from user input.
Re: PERL on web pages
by dragonchild (Archbishop) on Apr 17, 2003 at 14:47 UTC
    There is also a Perl extension to .NET.

    However, there is an extremely serious security flaw to doing any sort of Perl embedding. Perl is a language that allows you to drop down into the system. JavaScript is not. What this means is that if you are not careful, you can give someone control over your website very easily.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Don't go borrowing trouble. For programmers, this means Worry only about what you need to implement.

    Please remember that I'm crufty and crochety. All opinions are purely mine and all code is untested, unless otherwise specified.

Re: PERL on web pages
by tall_man (Parson) on Apr 17, 2003 at 15:21 UTC
    There's also a client-side plugin for perl you might like to look at: PerlPlusPlugin

    It can do perl/Tk applications that are embedded in the web page, for example.

Re: PERL on web pages
by artist (Parson) on Apr 17, 2003 at 15:26 UTC
    Answer:
    First, as the answer given by others: Yes, You can do perlscript on client side ie.. web browser provided perl is installed on the client. Most of the web users don't have perl installed on their machines.

    Meditation: - Perlscript by default
    Now that brings an interesting question. Javascript is not required to install on the client side an so is VBscript. They are integral part of the browser. Why not perlscript ?. Considering that there are plenty of applications written in perl as CGI application, we can certainly transform the logic from server side to client side without much modification. Browsers supporting perl script as integral part would be very good. Yes, the page developer may have to learn an additional language, but the thousands of perl programmer can get by without javascript/vbscript while creating the client-side interactive webpages.

    artist

Re: PERL on web pages
by hardburn (Abbot) on Apr 17, 2003 at 14:11 UTC

    Ahem.

    Perl = Language definition perl = Implmenentation of that language PERL = ???

    There's no such thing as 'PERL', unless it exists elsewhere in the English language.

    Now for your question: Before JavaScript existed, everyone did everything with server-side programs. Perl has fit this domain well. However, there are things on the client side (which is where JavaScript lives) that can make the process more efficent. For instance, say you have a form that has certain required fields. Before JavaScript, if any of these fields weren't filled out, the client would submit the form and the server would return an error saying the form wasn't completely filled out. With JavaScript, we can stop the user from submitting an invalid form in the first place, thus saving bandwidth and the time it takes for a server to execute the program to parse the form input.

    However, JavaScript can be shut off by the client. If the programmer in our example above said "JavaScript is doing the form validation, so there is no need to do it on the server side", then we could have a problem. A client that shuts off JavaScript would still be able to submit the form, and the server program would dutifully parse it. Thus, while JavaScript is often a useful tool, your Perl programs should be written to assume that it is shut off.

    ----
    I wanted to explore how Perl's closures can be manipulated, and ended up creating an object system by accident.
    -- Schemer

    Note: All code is untested, unless otherwise stated

Re: PERL on web pages
by nite_man (Deacon) on Apr 17, 2003 at 14:09 UTC
    You can use Perl scripts only on server side. If you need embedded Perl into html pages you can use EmbPerl, Mason or simply CGI.
          
    --------------------------------
    SV* sv_bless(SV* sv, HV* stash);