http://qs321.pair.com?node_id=811222


in reply to How does variable definition affect Perl performance ?

Aren't these variables global? As others said, initializing an empty variable should hardly matter; however setting to 0 a variable containing huge data can maybe take time.

  • Comment on Re: How does variable definition affect Perl performance ?

Replies are listed 'Best First'.
Re^2: How does variable definition affect Perl performance ?
by ikegami (Patriarch) on Dec 05, 2009 at 17:15 UTC

    setting to 0 a variable containing huge data can maybe take time.

    No. Why would assigning to a variable have to traverse the contained string? The length of the string contained doesn't matter. It's not even freed (which still wouldn't effect the time taken for long strings vs small strings).

    Or maybe you are talking about a scalar that contains the last reference to an object or a large structure? Destroying the structure can take time (e.g. if destructors need to be called), but I don't see the relevance. Destroying the structure will have to occur sooner or later. It's not going to speed up the OP's program by delaying when it occurs.