I'd recommend running all scripts under 'strict' to shed some insight on what's going wrong.  I could speculate most of the day as to why one script would offer results and another wouldn't, but a good rule of the thumb, is "use strict, or know exactly why you're not".
 
 
Thanks,
 
Tim Tompkins
----------------------------------------------
Programmer / IS Technician
http://www.arttoday.com/ 
 
 
----- Original Message -----
From: Andrei A. Voropaev <[EMAIL PROTECTED]>
To: Tim Tompkins <[EMAIL PROTECTED]>
Cc: Cédric Avena <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Sent: Wednesday, December 08, 1999 11:11 AM
Subject: Re: Associative Arrays problem

> Since the broken code worked in regular perl (and it was supposed to work
> because $rech and %rech are different things) and it didn't want to work
> in emb perl then there must be something strange about it.
>
> Was it an error in testing code (ie. checking $rech->{keys} instead of
> $rech{keys} at the end) or emb perl puts some restrictions on variables that
> I can use? Again. There's nothing wrong from the regular perl stand point if
> I say $rech = {}; and then $rech{'key'} = $value; perl creates different
> variables and as long as I use them correctly there shouldn't be a problem.
> Of course if I try to access $rech->{'key'} I'll get empty value later :)
>
> So, was it an error in real testing code? Because the code that I saw didn't
> contain that error.
>
> Andrei
>
>
> On Tue, Dec 07, 1999 at 12:18:32PM -0700, Tim Tompkins wrote:
> >
> > $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
> > >
> > >
>
> --
>

Reply via email to