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.

This FAQ explains what is happening and why you shouldn't do that:

perldoc -q "How can I use a variable as a variable name"


Also: http://perl.plover.com/varvarname.html


John -- use Perl; program fulfillment

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>




Reply via email to