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 > function of any two such net names combined in a pair (worst case > bound is N^2). Now, scalar referencing makes my life peaceful by > concatenating such names as pairs with some delimiter and store the > value directly. I need to do something like this cause I have to > perform several updates on these pair values depending upon certain > other conditions. In other words the burden of dereferencing is > totally on perl (which I am assuming is very fast ...as I do not know > how it does this.) If I can somehow know how perl does this, I might > be able make things more fast for my purpose. > > I just came to know that use strict; pragma does not allow you to use > such referecing technique. Does that mean there are any possible > hazards in using such referencing technique? And if there are any, can > someone please let me know about them. This wil help me in making my > code further robust. > > Also, I don't have any way to check if any wierd hazard occurs in > background and the pair values get disturbed because of that. It could > depend on the net names which can be anything except just an integer > or floating point number.
What you are using are called symbolic references, and the word "horrible" comes to mind. In general, do whatever it takes to satisfy the strict pragma until you fully understand the ramifications of defying it. 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? -- Peter Scott http://www.perlmedic.com/ http://www.perldebugged.com/ -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>