Slash Boxes
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
More | Login | Reply
Loading... please wait.
  • is there any reason why before, when you have the hash and array you didnt just mess a little with the symbol table to effectively make them point to the same variables, almost cutting memory use in half (well there is still the sort order array...) without having to give up your initial strategy for easy lookups?
    • What do you suggest "the same variables" are that they should point to?
      • Is it possible to use one big structure, where each of the three structures you want are sub-parts of it?

        As you construct the second and third parts, you can reference the first copy:

        my %a;
        $a{b} = { c => 'd' };
        $a{e}[0] = $a{b};

        Then, dumping it out, you see:

        # Notice the self reference...
        $VAR1 = {
                  'e' => [
                             'c' => 'd'

        • I looked at doing this, but managing all the references seemed like a colossal pain, and would still use a fair amount of memory over storing one simple structure with less cached lookups.
          Alternatively, perhaps you could keep just one copy of the structure, and have methods to look up value different ways as-needed, without having whole other structures pre-built, if they if they might not be used.
          That's what I did, effectively. There is on structure, an array of pairs, and methods that let you do the normal things. You can say "give me the values with name Foo" and it does. It just uses a linear search.

          Since Email::Simple 2 will have a Header object with a known interface, a more memory-hungry but faster implementation can be trivially substituted.