vit has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks,
I operate with large number of arrays of, say, 1000 strings where one string is of huge size and the rest are of small size.
Can this string of huge size negatively affect processing array efficiency?
If Yes or No, why?
With all flexibility of Perl, is it a good practice in terms of processing efficiency to store elements of large size variation in arrays.
  • Comment on Processing arrays with elements of different size

Replies are listed 'Best First'.
Re: Processing arrays with elements of different size
by almut (Canon) on Jun 14, 2009 at 15:38 UTC

    Storing a single huge string in an array does not negatively influence processing efficiency of the whole array, i.e. the other elements — if that's what you're thinking of. This is because what you store in one element does not influence the size of the other elements or the way they would be accessed internally.

Re: Processing arrays with elements of different size
by JavaFan (Canon) on Jun 14, 2009 at 15:34 UTC
    That depends on what you are doing while processing the array. If what you are doing is slow for long strings, than yes, it will affect processing. If what you are doing is independent of the length of the string, then it won't be affected.

    Internally, the strings themselves aren't stored in the arrays. Just pointers to structs that have pointers to structs that have a pointer to a character array (on the C level).