Cant set args to $r->arg(undef);

2000-08-13 Thread Greg Cope

Dear All

Although this in no longer important to me, I cannot appear to reset
$r->arg to an empty value.

I am writing a transhandler and if the args containted a certain value I
wanted to reset it to the args value without this value.

hence:


my $args = $r->args;

# remove value
$args =~ s/value//;

# resetting $r->args; 
$r->args($value);


If $args has more then value, then the args will be reset correctly.

However if $args, only contains value, and hence after the regex is now
empty, then the reset will not work, and $r->args() still contains the
orginal values...

Is this a bug / feature or just unexplained functionality ?

Greg Cope





my transhandler runs only once in each child ?!?

2000-08-13 Thread Greg Cope

Dear All

I've a bug somewhere that I cannot appear to spot..

I have writen parts of a transhandler to handle session's.  It works in
once in each child and then does not appear to be executed again.

I've looked through The Guide and could not see anything there, nor in
the 'Apache modules in Perl and C'.  I must be missing somehing (a clue
for a start ;-).

The obvious answer is that a variable is not being redefined /
initialised.

Any ideas appreciated.

Greg Cope

### some clues below (I hope)

I have these lines in my startup.pl:

use tinasm::Session();

$tinasm::Session::DEBUG = 1;
$tinasm::Session::DIR_MATCH = 'test';
$tinasm::Session::REDIRECT = 1;
$tinasm::Session::USE_ENV = 1;

# end of startup.pl, snippet #

part of the module below

# code snippet #
package tinasm::Session;

use strict;
use Apache;
use Apache::Constants qw(DECLINED REDIRECT OK);
use Digest::MD5 qw(md5_hex);

use constant SESSION_ID_LENGTH => 8;

use vars qw($DIR_MATCH $COOKIES_ONLY $ARGS_ONLY 
$DEBUG $REDIRECT $URI_FIRST $USE_ENV);

Apache->push_handlers("PerlTransHandler", \&transhandler);

sub transhandler {

my $r = shift;
unless ($r->uri =~ m!$DIR_MATCH!o) {
print STDERR "SESSION-MANAGER-$$-URI not matched\n"
if $DEBUG;
return DECLINED;
}

print STDERR "SESSION-MANAGER-$$-URI match\n" if $DEBUG;

. handler goes on for another 200 lines so I've snipped it - if
anyone wants to look at it drop me a line.




Problem with form data using mod_perl and CGI.pm

2000-08-13 Thread stevenl

I am running Linux 2.2, Apache 1.3.12, mod_perl 1.24, and CGI.pm 2.70.

If I declare a CGI variable using 'my' (see below) and use mod_perl, I
encounter problems with POST data.  On subsequent entries in the form,
it continues to use the old data.

The problem does not appear if I don't use 'my' (and therefore, unable
to 'use strict'), or if I disable mod_perl from my httpd.conf file.

You can test this out with these files.  First, run 'httpd -X'.  Then
enter some data in the form.  On the next submit, the data is not
changed.

Note: The perl script displays the current HTML file plus what you
just entered.


htdocs/form.html






Name: 










cgi-bin/form.pl
---
#!/usr/local/bin/perl -w

# Problem if declaring $query with 'my' and using
#   Apache 1.3.12, mod_perl 1.24, CGI.pm 2.70

use CGI;
my $query = new CGI;

print "Content-Type: text/html\n\n";

open(FD, "../htdocs/form.html") || die $!;
while () {
if (/^$/) {
printQueryParams();
}
else { print; }
}
close(FD);

sub printQueryParams
{
my @params = $query->param();

my ($arg, $val);
foreach $arg (@params) {
$val = $query->param($arg);
print "$arg = $val\n";
}
}



-Steven



Re: Problem with form data using mod_perl and CGI.pm

2000-08-13 Thread Jie Gao

On Sat, 12 Aug 2000, stevenl wrote:

> I am running Linux 2.2, Apache 1.3.12, mod_perl 1.24, and CGI.pm 2.70.
> 
> If I declare a CGI variable using 'my' (see below) and use mod_perl, I
> encounter problems with POST data.  On subsequent entries in the form,
> it continues to use the old data.
> 
> The problem does not appear if I don't use 'my' (and therefore, unable
> to 'use strict'), or if I disable mod_perl from my httpd.conf file.
> 
> You can test this out with these files.  First, run 'httpd -X'.  Then
> enter some data in the form.  On the next submit, the data is not
> changed.
> 
> Note: The perl script displays the current HTML file plus what you
> just entered.
> ...
 
http://perl.apache.org/guide/perl.html#my_Scoped_Variable_in_Nested_S



Jie




Re: my transhandler runs only once in each child ?!?

2000-08-13 Thread Matt Sergeant

On Sun, 13 Aug 2000, Greg Cope wrote:

> Apache->push_handlers("PerlTransHandler", \&transhandler);

push_handlers is temporary, not permanent. And this line only gets
executed once.

-- 


Fastnet Software Ltd. High Performance Web Specialists
Providing mod_perl, XML, Sybase and Oracle solutions
Email for training and consultancy availability.
http://sergeant.org | AxKit: http://axkit.org