Hi,
I come to this forum in the hope you actually have a few Perl experts amongst your ranks. I have tried 4 forums to date with no resolution to my seemingly simple problem.
I am a programmer by profession but have never delved into the World of Perl.
Problem:
I need to pass a variable from Perl to java script: In this case its an IP address.
I cannot change the page to something easier to use like php etc hence being forced to use Perl and Jscript.
Below is what experts have got up to now, however it does not work:
Perl code:
CODE
#!/usr/bin/perl -wT
use strict;
use CGI;
print CGI::header('text/text');
print qq/var IP="$ENV{'REMOTE_ADDR'}"/;
html jscript code:
CODE
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>Javascript Test</title>
<script LANGUAGE="JavaScript" SRC="/cgi-bin/ip"></SCRIPT>
</head>
<body>
<script LANGUAGE="JavaScript">alert(IP);</SCRIPT>
</body>
</html>
In the perl code someone said that the quotes need escaping like this:
CODE
print qq/var IP=\"$ENV{'REMOTE_ADDR'}\"/;
However when running the page I still get Var IP not defined as a jscript error.
Test urls are here
CODE
http://www.rimmelsoft.co.uk/iptest.htm
Perl is here
CODE
http://www.rimmelsoft.co.uk/cgi-bin/ip
Any help would gratefully be received
regards
nemo1966
PS the Perl cgi-bin is tested and working
PPS I know this can be done see:
CODE
http://www.searchnc.com/cgi-bin/myip.pl
This works in exactly the way I desribe, however I cannot find anyone with the knowledge to mimic its functionality.
This post has been edited by nemo1966: 12 Oct, 2007 - 12:52 AM