201 users online (0 members and 201 guests)  


  Results 1 to 5 of 5

Related

  1. Perl Help    Forum: CGI Perl Forum
    Replies: 1
  2. Replies: 1
  3. Replies: 1
  4. Replies: 0
  1. #1
    nemo1966's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    3

    Perl Var to Jscript Var

    oh dear - first post.
    I was trying to ask about a problem... however with it being a problem involving perl/cgi and a url... your system wont let me post it.
    WOW how useful is that......
    So what do you want me to do? post 5 completely random posts just so I can pose my problem?

  2. #2
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Perl Var to Jscript Var

    Post the URL without a hyperlink, or else post the source code for the page. And of course, you'll want to post your problem statement as well.
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  3. #3
    nemo1966's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    3

    Re: Perl Var to Jscript Var

    The problem I have is I am trying to pass a variable from Perl to be able to use it in Javascript. In this case the remote IP address but that is incidental.Up to now I have a perl script in my cgi-bin called ip the code in the file is:
    Code:
    #!/usr/bin/perl -wTuse strict;use CGI;print CGI::header('text/text');print qq/var IP="$ENV{'REMOTE_ADDR'}"/;
    (; separates the perl lines - for some reason the quirky editor doeant seem to like code even in code brackets)The page that calls it is www (dot) rimmelsoft.co.uk/iptest.htm. As you can see the perl page should expose a var called IP to the jscript, but for some reason it doesn't. Can anyone help? I've been on this for 2 weeks now and my hair is starting to fall out.thanks in advance.

  4. #4
    vinyl-junkie's Avatar
    Moderator

    Status
    Offline
    Join Date
    Sep 2005
    Posts
    721

    Re: Perl Var to Jscript Var

    You need to escape special characters with a backslash, so instead of this:

    Code:
    #!/usr/bin/perl -wTuse strict;
    use CGI;
    print CGI::header('text/text');
    print qq/var IP="$ENV{'REMOTE_ADDR'}"/;
    you need this:

    Code:
    #!/usr/bin/perl -wTuse strict;
    use CGI;
    print CGI::header('text/text');
    print qq/var IP=\"$ENV{'REMOTE_ADDR'}\"/;
    Music Around The World - Collecting tips, trade
    and want lists, album reviews, & more

  5. #5
    nemo1966's Avatar
    New User

    Status
    Offline
    Join Date
    Oct 2007
    Posts
    3

    Re: Perl Var to Jscript Var

    That didn't seem to have any effect. Thanks for the reply though - perhaps getting a little nearer.



Tags for this Thread