Hi darren

Did you try starting apache with "httpd -X".  It spawns only one process and that helps keep things in order, as far as variable values.  You can try trouble shooting with that.

 darren chamberlain <[EMAIL PROTECTED]>wrote:

* Michael Drons <[EMAIL PROTECTED]>[2002-08-13 01:55]:
> Thanks for the link. I actually don't use functions.
> Everything is mostly in MAIN. Here is a snip of code:
>
> #!/usr/bin/perl -wT
> use strict;
> print "";
> my $r = Apache->request;
> $r->content_type("text/html");
> $r->status(200);
> my $auth_type = $r->auth_type;
> $cookie=$auth_type->key;
> ($user,$hash)=split(/:/,$cookie);
> read(STDIN, my $buffer, $ENV{'CONTENT_LENGTH'});
> my @pairs = split(/&/, $buffer);
> foreach my $pair (@pairs) {
> ....
> }
>
> What I am doing wrong? Everytime the script runs the
> values of the variables coming in change. Should I
> use the delete function and delete all of the
> variables at the end of the script? @pairs is what
> should change, but sometimes does not. I have tried
> to add a undef @pairs before the split, but no luck.

Are you sure that this is the code that is running? It doesn't compile:

$ perl
#!/usr/bin/perl -wT
use strict;
print "";
my $r = Apache->request;
$r->content_type("text/html");
$r->status(200);
my $auth_type = $r->auth_type;
$cookie=$auth_type->key;
($user,$hash)=split(/:/,$cookie);
read(STDIN, my $buffer, $ENV{'CONTENT_LENGTH'});
my @pairs = split(/&/, $buffer);
foreach my $pair (@pairs) { }
Global symbol "$cookie" requires explicit package name at - line 7.
Global symbol "$user" requires explicit package name at - line 8.
Global symbol "$hash" requires explicit package name at - line 8.
Global symbol "$cookie" requires explicit package name at - line 8.
Execution of - aborted due to compilation errors

Make those global symbols ($cookie, $user, and $hash) lexical (declare
with my) and the code will both compile and do what you expect (i.e.,
not maintain values from call to call).

You'll also want to print things *after* you set the content type and
status, not before.

(darren)

--
The biggest difference between time and space is that you can't
reuse time.
-- Merrick Furst



Do You Yahoo!?
HotJobs, a Yahoo! service - Search Thousands of New Jobs

Reply via email to