We help IT Professionals succeed at work.
Get Started

Perl sub in html code

bt707 asked
Last Modified: 2012-05-12
I have some web cgi's, mostly perl with some html and javascript part in them.

I have a section that runs that has html in it, which it calls a javascript session timer by using $QandASessionTimer in the html code it will then call the timer code which is shown below in the attached code.

Not sure how to ask this since I cannot post the whole thing.

What I'm trying to do is to put the $QandASessionTimer into a subroutine and call it with &QandASessionTimer rather than $QandASessionTimer

Can anyone give me a clue why in the html part I can use $QandASessionTimer but not &QandASessionTimer to call a sub?

<script type="text/javaScript">
var starttime = 1200;
var endtime = 0;

function timechecker() {

    if (starttime >= endtime) {

      setTimeout('countdowner()', 1000)
    else {
      alert("Your session has timed out you will now be returned to the login page.");
      window.location = "$RedirectLocation";

  function countdowner(){
      var mins = Math.floor (starttime /60);
      var secs = Math.floor (starttime - (mins*60));
      if (secs < 10) {
        secs = '0' + secs;
      var display = '<center><font size=1>Session timeout in:<\\/font><br \\/>' + mins + ":" + secs + '<center>';

      document.getElementById('clock').innerHTML = display;
      starttime = starttime - 1;


<span id='clock'></span>

Open in new window

Watch Question
This problem has been solved!
Unlock 1 Answer and 9 Comments.
See Answer
Why Experts Exchange?

Experts Exchange always has the answer, or at the least points me in the correct direction! It is like having another employee that is extremely experienced.

Jim Murphy
Programmer at Smart IT Solutions

When asked, what has been your best career decision?

Deciding to stick with EE.

Mohamed Asif
Technical Department Head

Being involved with EE helped me to grow personally and professionally.

Carl Webster
CTP, Sr Infrastructure Consultant
Ask ANY Question

Connect with Certified Experts to gain insight and support on specific technology challenges including:

  • Troubleshooting
  • Research
  • Professional Opinions
Did You Know?

We've partnered with two important charities to provide clean water and computer science education to those who need it most. READ MORE