Many Perl programmers are involved in the web, and for many that includes JavaScript. This is a thought for how these exiles may find ways to apply Perl wisdom.

JavaScript is definitely a foreign land. I have pity for those who cannot easily know whether 2+2 will give 4 or '22'. But here are some familiar sights to look for.

With current browsers JavaScript supports regular expressions. While they are called Perl compatible they are not in truth Ilya compatible. But they do provide a familiar sight.

Advanced monks may recognize that JavaScript supports anonymous functions with full closures. This is very nice if you have learned to use thse in Perl. However many have not.

And I have saved the best for last. Did you know that you can use a JavaScript variable in the same way you would use a Perl hash? The language is different, but the properties of the object are your keys, and the values are your values. :-)

Replies are listed 'Best First'.
RE: A thought for JavaScript exiles
by toadi (Chaplain) on Aug 07, 2000 at 12:48 UTC
    merlyn had a rambling about javascript ...

    Well IMHO drop javascript, I don't see any real use for javascript in web-programming. It's browser-dependant so you have no control over it!!!!!

    When I program server-side I know I have the maximum of contol over what I'm programming and displaying.

    --
    My opinions may have changed,
    but not the fact that I am right

      Javascript can be useful for validation of forms without having to make a trip back to the server.

      Roy Alan

        But you have to repeat that same validation check on the server side as well, and still have a way for the server-side validation to allow for reentry on error.

        So if you enjoy writing the code twice, in two different languages, and maintaining that, that's fine.

        If you don't have unlimited programmer resources, then write only the serverside check. Don't skimp and write only the clientside check, unless you want your name on a posting as a CERT warning or BugTraq posting as the "loser that wrote this code" {grin}.

        -- Randal L. Schwartz, Perl hacker

        This is very true, and is actually the only time I ever use javascript at all.

        I often use javascript in perl functions to validate user input, rather than having my perl script check the inputs.

        Something like this ..

        print<<CHECK; <script language="JavaScript"> if(window.confirm('Really delete $entry?')) { location.href=("$0&aktion=Delete&confirm=1"); } else { history.back(); } </script> CHECK
        Then I can check the value of $confirm with a cute little pop up box, and do whatever is needed to, without ever coming back to the server.