Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^3: Add value from one array element into another of same ID

by BillKSmith (Monsignor)
on May 28, 2021 at 03:24 UTC ( #11133192=note: print w/replies, xml ) Need Help??


in reply to Re^2: Add value from one array element into another of same ID
in thread Add value from one array element into another of same ID

You can fix this problem by adding one line.
... $result[-1]->{CODE} = $temp->{CODE}; $result[-1]->{Number} = $temp->{Number}; ...

I thought that I understood your requirements, but now I am not sure. I now think that you want one output record for each ID. For each ID, the input should contain one named record and possible one unnamed one. Output for any other input would be undefined. We probably cannot make any assumptions about record order. In the single record case, we output that record. In the two record case, we output the unnamed record with the value of its name field replaced with the name from the other record.

Bill

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://11133192]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (5)
As of 2021-12-05 14:43 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    R or B?



    Results (31 votes). Check out past polls.

    Notices?