in reply to Re^2: cannot Access the sub-routine
in thread cannot Access the sub-routine

Then your enhancements are probably the source of the problem. :-) You could try posting just the routines you've changed, people generally can't be bothered to go through pages and pages of code to find someone else's syntax error :-)

Have you looked at your error-logs already? Perl might have told you something important.

If you really can't narrow it down, and the file's really big, try putting the code on some server and make a link to it.

Replies are listed 'Best First'.
Re^4: cannot Access the sub-routine
by blazix (Initiate) on Jul 19, 2004 at 18:43 UTC
    I added a subroutine to the existing script .
    sub readCookies
    {
    use CGI qw/:standard/;
    if (my $time = cookie('WBSession')) {

    $testVal = "Cookie Exists";

    } else {
    $testVal = "Cookie Does Not Exists";
    }

    return $testVal;
    }
    I also added below one line which prints on the top of the screen.
    print "Content-type: text/html \n";
    print "set-cookie: WBSession=$sessionInfo; path=/cgi-bin;\n\n";
    print "set-cookie: TestCookie=$sessionInfo; path=/cgi-bin;\n\n";// added and this gets prints
    If you wish I would like to email the code which I am working on
    Thanks
    blazix
Re^4: cannot Access the sub-routine
by Anonymous Monk on Jul 19, 2004 at 22:08 UTC
    Hello Monks,
    Now I got to know why I am getting the error and fixed it.I appreciate your immediate response.

    Actually I am trying to create more than one cookie but whichever is set first that is remaining as the cookie and other is getting printed on the screen at the top.So what should I do to have more than one cookies.
    I donot want to create array of cookies.Since this is existing application I donot want to disturb the one which application is already using.
    So guide me to right approach.

    Blazix
Re^4: cannot Access the sub-routine
by Anonymous Monk on Jul 19, 2004 at 18:18 UTC
    If you wish I would like to email to you.
      The source I just added is
      sub readCookies
      {
      use CGI qw/:standard/;
      if (my $time = cookie('WBSession')) {

      $testVal = "Cookie Exists";

      } else {
      $testVal = "Cookie Does Not Exists";
      }

      return $testVal;
      }
      And I tried adding the below line to the code existing code.
      print "set-cookie: WBSession=$sessionInfo; path=/cgi-bin;\n\n";
      print "set-cookie: TestCookie=$testVal; \n\n";//added
      Whenever I add this I get the set-cookie: TestCookie=$testVal printed on the top of the screen. why is it like this ?

        You see those because something has already finished printing headers to the browser. Your print statements print headers; they must come before all other output.

        Something somewhere else in your program is printing headers. If you want to set cookies, you'll have to print them wherever that something is in your program. It may be a call to header() or something like print "Content-type: text/html\n\n".