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

Re: Re: Uniion of 2 hashes don't work.

by toadi (Chaplain)
on Jan 10, 2003 at 13:20 UTC ( #225784=note: print w/ replies, xml ) Need Help??

in reply to Re: Uniion of 2 hashes don't work.
in thread Union of 2 hashes don't work.

Well I actually did it on a other way...

- I had 2 queries from a db.
- I wanted to write the results in a csv(fixed order so tie).
- But in the first query i had a key login and if this key existed in second query I wanted the data from both queries as a union on one line in the csv.(both had common fields and unique fields to the both queries)

I solved it on db-level:
- I made a new table in oracle where i put the data from query one. Then do a insert or update(to login) with second query.(first i did it with tempory tables in memory, but dumped that idea).
- Finally I read out that table and make the csv.

This solution is also good for knowing on which day what data should be in that csv. If something went wrong with creating the csv and/or sending it to the outside party. I easily can redo this step, because of this table.

For the ones who would be interested hacked a small sample, how i could do it on perl-level:

# record 1 $login = "me"; $name = "toadi"; $email = ""; $contract = "SERVICE"; $csv{$login}{name}=$name; $csv{$login}{email}=$email; $csv{$login}{contract}=$contract; # record 2 $login = "u"; $name = "other one"; $email = ""; $contract = "Programming"; $csv{$login}{name}=$name; $csv{$login}{email}=$email; $csv{$login}{contract}=$contract; foreach $login ( keys %csv ) { print "$csv{$login}{name},$csv{$login}{email},$csv{$login}{rek +nr},$csv{$login}{contract}\n"; }
So if the key exits, it will write over the needed values. If key not exits it wil make a new entry...

My opinions may have changed,
but not the fact that I am right

Comment on Re: Re: Uniion of 2 hashes don't work.
Download Code

Log In?

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

How do I use this? | Other CB clients
Other Users?
Others studying the Monastery: (3)
As of 2015-11-29 18:51 GMT
Find Nodes?
    Voting Booth?

    What would be the most significant thing to happen if a rope (or wire) tied the Earth and the Moon together?

    Results (752 votes), past polls