in reply to Re: Combine duplicated keys in Hash array
in thread Combine duplicated keys in Hash array

Thank you! This most mimics what I'm going for. Could you explain this behalf?
my $height_0 = $curr_data->[0][2]; my $height_1 = $curr_data->[1][2]; my $markername_0 = $curr_data->[0][0]; my $markername_1 = $curr_data->[1][0];

Replies are listed 'Best First'.
Re^3: Combine duplicated keys in Hash array
by BillKSmith (Monsignor) on Jul 05, 2020 at 19:00 UTC

    My use of push changed the nature of your structure %data from a hash of arrays to a hash of arrays of arrays. (refer: perldsc) Please uncomment my "print Dump" statement and run my code again. Refer to that dump as you read my explanation.

    The keys of the hash %data are the instances of $curr_identifier. The corresponding values are array refs. Each of these refers to an array of two elements (one for each line associated with the curr_identifier). Each of these elements is itself a reference to an array (in fact, each array is an instance of your originally "@result".)

    My for loop iterates through the keys ($curr_identifier) of the hash %data. For each key, it stores the corresponding value (A reference to an array of arrays) as $curr_data. The next four statements, which you explicitly asked about, dereference that reference (Section "Using References" in perlref) to get the two values of height and the two values of markername. I appended a zero or a one to each name to indicate which of the pair of lines it came from.

    Bill