jquery - Number appearing in Perl-generated JavaScript code instead of "$(" -


on site i'm working on there random numbers appearing in simple bit of jquery.

instead of what's meant appear, these numbers — 48, etc. — appear @ beginning. this:

<script type="text/javascript">     48 48document).ready(function () {     48 48".closed").click(function () {                  48 48this).find("div.but").toggleclass('plus').toggleclass('minus');                         48 48this).toggleclass('closed').toggleclass('open');             });         });         </script> 

i can't begin imagine why spit out when hard-coded site , there's no external file or anything.

ok, since it's perl need escape $(, how? took @ perl documentation , felt i'd been punched.

do use single quotes instead of double quotes?

<script type="text/javascript">     $(document).ready(function () {       $('.closed').click(function () {                   $(this).find('div.but').toggleclass('plus').toggleclass('minus');         $(this).toggleclass('closed').toggleclass('open');           });   }); </script> 

here's full perl script. it's header of site.

########################### ## meta data , headers ## ###########################  $be_strict = 0;    # 1 = 404 on page not found if ((!$title{$loadpage} || !$h1{$loadpage} || !$description{$loadpage} || !$keywords{$loadpage} || !$breadcrumb{$loadpage}) && $be_strict) {   print "status: 302 found\r\n" .       "location: http://www.realots.co/404/\r\n" .       "\r\n";   exit(0); }   if ($action) {    #############################   ## highscore page seo hack ##   #############################    if ($action eq "fish") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>fishing skill</b>";     $h1{'highscores'}             = "realots fishing highscores";     $title{'highscores'}          = "realots top fishing skill";     $description{'highscores'}    = "fishing skill highscore list of our realots. check out these amazing fishermen!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,fishing,top fishing";   }   elsif ($action eq "ml") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>magic level</b>";     $h1{'highscores'}             = "realots magic highscores";     $title{'highscores'}          = "realots top magic level";     $description{'highscores'}    = "magic level highscore list of our realots. check out these fearsome mages!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,magic,top magic";   }   elsif ($action eq "sword") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>sword fighting</b>";     $h1{'highscores'}             = "realots sword fighting highscores";     $title{'highscores'}          = "realots top sword fighters";     $description{'highscores'}    = "sword fighting highscore list of our realots. fear mighty sword wielder!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,sword,top sword";   }   elsif ($action eq "axe") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>axe fighting</b>";     $h1{'highscores'}             = "realots axe fighting highscores";     $title{'highscores'}          = "realots top axe fighters";     $description{'highscores'}    = "axe fighting highscore list of our realots. behold these savage beasts amazing axe skills!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,axe,top axe,axe fighting";   }   elsif ($action eq "club") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>club fighting</b>";     $h1{'highscores'}             = "realots club fighting highscores";     $title{'highscores'}          = "realots top club fighters";     $description{'highscores'}    = "club fighting highscore list of our realots. caveman-like agility around!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,club,top club,club fighting";   }   elsif ($action eq "dist") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>distance fighting</b>";     $h1{'highscores'}             = "realots distance fighting highscores";     $title{'highscores'}          = "realots top distance fighters";     $description{'highscores'}    = "distance fighting highscore list of our realots. death afar, raining sky!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,distance,top distance,distance fighting";   }   elsif ($action eq "shield") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>shielding</b>";     $h1{'highscores'}             = "realots shielding highscores";     $title{'highscores'}          = "realots top shielding";     $description{'highscores'}    = "shielding highscore list of our realots. these tanks able withstand tremendeous blows!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,shielding,top shielding";   }   elsif ($action eq "fist") {     $breadcrumb{'highscores'}     = "<a href='/'>realots</a> &raquo; <a href='/highscores/'>highscores</a> &raquo; <b>fist fighting</b>";     $h1{'highscores'}             = "realots fist fighting highscores";     $title{'highscores'}          = "realots top fist fighters";     $description{'highscores'}    = "fist fighting highscore list of our realots. had special training sensai chuck norris!";     $keywords{'highscores'}       = "realots,otserv,tibia,highscore,hiscores,fist,top fist,fist fighting";   } }  #&print_header(); $web_content .= qq{ <!doctype html public "-//w3c//dtd html 4.01 transitional//en" "http://www.w3.org/tr/html4/loose.dtd"> <html>   <head>     <meta http-equiv="content-type" content="text/html; charset=iso-8859-1">      <title>$title{$loadpage}</title>     <meta name="google-site-verification" content="z97w94kp7mliogiamaycfa4lp4i5hckxdncrarxkbxk" />     <meta name="google-site-verification" content="i5htpl8jlrcdrwk3jd83qifdbks4g_rmwhlxeq94jlu" />     <style type="text/css">       table.outlined {         border-width: 1px;         order-style: solid;         border-color: #9999cc;         border-collapse: separate;       }       a.suggestions:visited{color:#0000ff;text-decoration:none;}       a.suggestions:link{color:#0000ff;text-decoration:none;}       a.suggestions:hover{color:#305997;text-decoration:none;}  .trans {         filter:alpha(opacity=50);         -moz-opacity:0.5;         -khtml-opacity: 0.5;         opacity: 0.5; }      </style> <!--[if ie 6]> <![endif]--> <!--[if ie 6]> <style type="text/css"> html { overflow-y: hidden; } body { overflow-y: auto; } img#bg { position:absolute; z-index:-1; } #content { position:static; } </style> <![endif]-->  };  if ($no_index{$loadpage}) {   $web_content .= qq{    <meta name="robots" content="noindex,nofollow,noarchive,nosnippet" />}; } else {   $web_content .= qq{    <meta name="robots" content="index,follow" />}; }  $web_content .= qq{     <meta name="keywords" content="$keywords{$loadpage}">     <meta name="description" content="$description{$loadpage}">     <meta name="author" content="realots" />     <meta name="expires" content="never" />     <link rel="stylesheet" type="text/css" href="/images/style.css" />     <script type="text/javascript" src="http://www.mollie.nl/partners/js/96481.js"></script>      <script src="https://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js"></script>      <script type="text/javascript">     $(document).ready(function () {     $(".closed").click(function () {           $(this).find("div.but").toggleclass('plus').toggleclass('minus');           $(this).toggleclass('closed').toggleclass('open');      });  });      </script>       </head> }; 

$( perl predefined variable, expanding process's group id list.

if on machine supports membership in multiple groups simultaneously, gives space separated list of groups in. first number 1 returned getgid() , , subsequent ones getgroups() , 1 of may same first number.

see perlvar docs details.

to avoid problem, make sure escape $( (and other javascript $ chars) in perl strings, or use '' instead of "" avoid interpolation.

bad:

$html = "$(document).ready(...)"; 

good:

$html = "\$(document).ready(...)"; $html = '$(document).ready(...)'; 

in code above, example, script section should be:

<script type="text/javascript">   \$(document).ready(function () {     \$(".closed").click(function () {        \$(this).find("div.but").toggleclass('plus').toggleclass('minus');       \$(this).toggleclass('closed').toggleclass('open');      });       }); </script> 

Comments

Popular posts from this blog

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

python - pip wont install .WHL files -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -