in reply to Re: Matching up XML tags in 2 arrays
in thread Matching up XML tags in 2 arrays

Wouldn't that mean that if two tags had the same content, there would be a collision?

Eg <Tag id=1>He</Tag> Walked Like <Tag id=2>He</Tag> Talked. Then there would be a collision of some kind between the two tags containg 'He'.

What does perl do in a situation like this? Is the first tag simply replaced by the second?

Replies are listed 'Best First'.
Re^3: Matching up XML tags in 2 arrays
by bobf (Monsignor) on Jan 16, 2007 at 03:16 UTC

    That's why ikegami suggested using a hash of arrays. If you push a new tag ID onto the array you will be able to track all occurrences without overwriting existing data. Your example would look something like this:

    %text = ( 'He' => [ 1, 2 ], ...

    If, on the other hand, you were using a straight hash:

    %text = ( 'He' => 1, ...
    then yes, the first tag would be replaced by the second.

    You may find perldsc and our Tutorials section (specifically Data Types and Variables) helpful.