Loading ...
Sorry, an error occurred while loading the content.

Re: [PBML] Lexical ???

Expand Messages
  • Jeff 'japhy' Pinyan
    ... That means that somewhere else in the code, you have my @rawCookies which makes @rawCookies a LEXICAL variable. Because it s lexical, you can t
    Message 1 of 12 , Sep 3, 2002
    • 0 Attachment
      On Sep 4, Gordon Stewart said:

      >--------------------
      >Can't localize lexical variable @rawCookies at
      >/www/g/gorstew/cgi-bin/test1/view.cgi line 1070.
      >--------------------

      That means that somewhere else in the code, you have

      my @rawCookies

      which makes @rawCookies a LEXICAL variable. Because it's lexical, you
      can't local()-ize it.

      But you shouldn't be using local(). Change your local()s to my()s. There
      are only a few instances where local() is important, and you'll probably
      never run into them.

      >sub getCookies {
      > # cookies are seperated by a semicolon and a space, this will split
      > # them and return a hash of cookies
      > local(@rawCookies) = split (/; /,$ENV{'HTTP_COOKIE'});
      > local(%cookies);
      >
      > foreach(@rawCookies){
      > ($key, $val) = split (/=/,$_);
      > $cookies{$key} = $val;
      > }
      >
      > return %cookies;
      >}

      You might want to consider using a module such as CGI::Cookie to work with
      cookies.

      --
      Jeff "japhy" Pinyan japhy@... http://www.pobox.com/~japhy/
      RPI Acacia brother #734 http://www.perlmonks.org/ http://www.cpan.org/
      ** Look for "Regular Expressions in Perl" published by Manning, in 2002 **
      <stu> what does y/// stand for? <tenderpuss> why, yansliterate of course.
      [ I'm looking for programming work. If you like my work, let me know. ]
    Your message has been successfully submitted and would be delivered to recipients shortly.