D
david scholefield
Not easily being able to look into the perl interpreter code, does anyone
have any idea on whether or not declaring a new _my_ variable is more
efficient when declared inside a loop (creating a new instance every
time), or declared outside the loop, or whether there is no great
difference.
By efficiency I mean both
space, and speed (though as the loop body completes each iteration I assume
the variable reference count reduces to zero and it is destroyed anyway, so
I guess space isn't a issue?)
e.g.
{
my $someVal;
while ($loopcontrol)
{
... use $someval in some way
}
}
is more efficient than (?)
while ($loopcontrol)
{
my $someVal;
... use $someval as before
}
I realise that there is a functional difference in that by declaring inside
the loop, any old value is over-written, but assuming that isn't an issue...
david
emology.com
have any idea on whether or not declaring a new _my_ variable is more
efficient when declared inside a loop (creating a new instance every
time), or declared outside the loop, or whether there is no great
difference.
By efficiency I mean both
space, and speed (though as the loop body completes each iteration I assume
the variable reference count reduces to zero and it is destroyed anyway, so
I guess space isn't a issue?)
e.g.
{
my $someVal;
while ($loopcontrol)
{
... use $someval in some way
}
}
is more efficient than (?)
while ($loopcontrol)
{
my $someVal;
... use $someval as before
}
I realise that there is a functional difference in that by declaring inside
the loop, any old value is over-written, but assuming that isn't an issue...
david
emology.com