Ken Gillett wrote:
I have a script that creates a hash, up to several thousand key=>value
pairs. Each value is a string that is created by adding to it
repeatedly, maybe hundreds of times, each addition probably about 10 bytes.
I can do this in (at least) 2 ways. One is to repeatedly concatenate (
.= ) the additional string onto a scalar variable and then, once it has
been fully created, to add this variable to the hash with its
appropriate key. The other is to directly add onto the hash value
itself, no other variable involved.
My question is:-
Which is faster in operation?
I don't know enough about the internal workings of perl's memory
structures (actually I know nothing about that:-) to be able to hazard a
guess at this. Maybe it makes no measurable difference, but maybe one is
definitely the better modus operandi.
Can anyone answer this?
Ken G i l l e t t
_/_/_/_/_/_/_/_/_/
perldoc Benchmark
Check the list archives for examples of usage on other problems.
http://danconia.org
--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]
<http://learn.perl.org/> <http://learn.perl.org/first-response>