Hi.

On 4 Aug 2004 at 14:20, Tom Schindl wrote:

> Oh. I see not a very heavy loaded service :-). Are you running the
> server on win32?

No slackware linux with Apache/1.3.26 (Unix) mod_perl/1.27

> > That besides, the above method didn't work (see mail to list 
> > "Accessing form multiples". I think you replied to it. Whenever I
> > tried to loop through the incoming list of
> > "user=dermot+paikkos&user=joe+blogs" I was only getting the first
> > user.
> 
> Although that's perl here's the explanation.
> 
> because $r->param( "key" ) can be used in 2 contexts
> (see perldoc -f wantarray). That's something very specific to
> perl which you maybe not familiar with when have used langs
> like java, c++, ...:
Ha yes, well no, perl is the only language I have tried. I am a 
sysadmin not a developer. This is more like a hobby.

Yes I have been stung by this in the past but with Regex. I think I 
was told i was calling it in the wrong context and I should use a 
slice.

> 1. List-Context    => returns list of values:
> ---------------------------------------------
> Example for list contexts:
> @vals = $r->param("keys")
> foreach( $r->param("keys") )
> @hash_slice{$r->param("keys")}
> 
> 2. Scalar-Context => returns first value of list:
> -------------------------------------------------
> $val = $r->param("keys")
> $hash{$r->param("keys")}
> 
> 
> > Still not sure why I can do 
> > 
> > my $r=Apache::Request->new(shift);
> > my @users;
> > foreach my $param ($r->param) {
> >     push(@users,$r->param($param));
> > } 
> 
> here you are in list context.
> 
> @user{$apr->param("keys")} = ();
> map { $user{$_} = 0 } keys %user;

This looks tastey. I could learn something here. I think that is a 
slice....not too familar with map....better go back to the books. 
This is what was told to consider but to be honest I am not familiar 
with the hash slices or maps so I opted to stick the lot in an array 
as per your 2nd example.

> > and not:
> > 
> > my $r=Apache::Request->new(shift);
> > my %users;
> > foreach my $param ($r->parm) {
> >     %users{$r->param($param) = 0;
> > }
> > 
> 
> That's not valid syntax at all if you meant $user{$r->param($param)} =
> 0 then you are here in scalar context.

Opps, I meant $users{$r->param($param)}. Not that it would have 
worked.

Sorry to labour on this. Better get off it now of the list grumble.
Thanx again Tom.
Dp.



-- 
Report problems: http://perl.apache.org/bugs/
Mail list info: http://perl.apache.org/maillist/modperl.html
List etiquette: http://perl.apache.org/maillist/email-etiquette.html

Reply via email to