in reply to Re^2: share array of hashes between main program and thread
in thread share array of hashes between main program and thread

how could i add an additional single hash to a line i ($i) of my array of hashes

Do you mean: how can I add an extra key-value pair to one of the hashes in my AoH?

Assuming you do, like this:

$Array[ $i ]{ newKey } = 'newValue'.

Once the reference is shared (or is a reference to a shared hash--same thing), adding pairs is just the same as normal. Because scalars, (keys and values) are shared by value. Only references are shared by reference.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
RIP PCW It is as I've been saying!(Audio until 20090817)

Replies are listed 'Best First'.
Re^4: share array of hashes between main program and thread
by Adler (Novice) on Nov 11, 2009 at 11:54 UTC
    are the two command equivalent?
    $Array[ $i ]{ newKey } = 'newValue' $Array[ $i ]{ newKey }->'newValue'
    thanks
      are the two command equivalent?

      Not even slightly, as the latter is illegal syntax:

      perl -mstrict -cwle"$Array[ $i ]{ newKey }->'newValue'" String found where operator expected at -e line 1, near "->'newValue'" (Missing operator before 'newValue'?) syntax error at -e line 1, near "->'newValue'" -e had compilation errors.

      Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
      "Science is about questioning the status quo. Questioning authority".
      In the absence of evidence, opinion is indistinguishable from prejudice.