"Peter Scott" <[EMAIL PROTECTED]> wrote in message news:[EMAIL PROTECTED] > On Thu, 12 May 2005 21:10:44 +0530, Madhur Kashyap wrote: > > > The chunk of perl code written below shows the way I have been using > > the scalar referencing technique available in perl. > > > > $a="X15565/X123/35"; > > $b="n245"; > > ${$a."\t".$b}=0.598; ### <<== Scalar Referencing > > .... > > $x=tracename (1056.45,1076.56); ## returns X15565/X123/35 > > $y=tracename (234,34.89); ## returns n245 > > ${$x."\t".$y}+=0.63; ### makes life very simple > > > > For my application, the scalars held by $a and $b are actually some > > net names. Typically, I will have, say around 300,000-400,000 such > > names. Also, there is a physical quantity (floating number) which is a <snip> > > I see no reason why you can't just use a hash lookup, which should be just > as fast. I cannot tell from your code what property you are storing, > which is also a red flag. Let's say that it is some interconnection cost: > > my %cost; > [...] > $cost{"$x\t$y"} += 0.63; > > See how more readable that is? >
Or even simpler still, a multidemensional hash: $cost{$x}{$y} += 0.63; Todd W. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>