$rech is a hashref, not a hash. de-reference it with arrow notation.
%toto = ( "001" => 1, "002" => 2, "003" => 3 );
%tato = ( "004"=> 4, "002"=> 5, "005"=> 6 );
$rech = {};
$nb = 2;
for $mot (keys %toto) { $rech->{$mot} = 1; }
for $mot (keys %tato) { if (defined $rech->{$mot}) { $rech->{$mot}++; } }
$recherche = join(',', map { "'$_'" } grep { $rech->{$_}==$nb } (keys
%$rech));
-------- DUMP ----------
$rech = {
'001' => 1,
'002' => 2,
'003' => 1
};
$recherche = '002'
Thanks,
Tim Tompkins
----------------------------------------------
Programmer / IS Technician
http://www.arttoday.com/
----- Original Message -----
From: Cédric Avena <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Tuesday, December 07, 1999 6:27 AM
Subject: Associative Arrays problem
> Hi,
>
> I'm using associative arrays in ASP 0.16, but it doesn't work... I have
> taken the same portion of code in a .pl file and execute it, it works...
>
> Do associative arrays work with modperl ? Could anybody help me ?
>
> An extract of my program:
> %toto = ( "001" => 1, "002" => 2, "003" => 3 );
> %tato = ( "004"=> 4, "002"=> 5, "005"=> 6 );
> $rech = {};
> $nb = 2;
> for $mot (keys %toto) { $rech{$mot} = 1; }
> for $mot (keys %tato) { if (defined $rech{$mot}) { $rech{$mot}++; } }
> $recherche = "";
> for $mot (keys %rech) { if ($rech{$mot}==$nb) { $recherche .=
> "'$mot',"; } }
> chop($recherche);
>
> $recherche equals "'002'" with single perl programming
> $recherche equals "" with ASP programming
>
> Thanks in advance...
> --
> Cedric Avena
> WAW - Web At Work - Tel: +33 (0)491 812 145
> mailto:[EMAIL PROTECTED] - http://www.waw.com
>
>