in reply to How do I send information to Javascript from perl?

You probably just need to interpolate the Perl values into the JavaScript code as it's sent.

For example, if "foo" is a value you want the JS code to see, your program should at some point do something like this in the midst of transmitting JS code:

print "foo = '\Q$foo\E'\n";

NOTE: Using \Q should protect against most metacharacters in the variable, but you should be quite careful to determine if it does what's appropriate for JS quoting conventions.

    -- Chip Salzenberg, Free-Floating Agent of Chaos

Replies are listed 'Best First'.
Re: Re: How do I send information to Javascript from perl?
by Parham (Friar) on Jan 01, 2002 at 03:37 UTC
    one approach would be to redirect to an html file with a query string after you've done all your processing in your perl such as:
    $username = 'username'; print "Location: html.html?username=$username\n\n";
    from there, you can simply grab the variable on the html using this:
    <script language="JavaScript"><!-- if (location.search.length > 0) eval('var ' + location.search.substring(1)); //--></script>