Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: Hashes with Multiple Keys and Combining Them

by didess (Sexton)
on Sep 10, 2008 at 21:10 UTC ( [id://710469]=note: print w/replies, xml ) Need Help??


in reply to Hashes with Multiple Keys and Combining Them

Hi, This code should satisfy your demand:
Data are in a hash whose key is the ID and associated value is an array with the first elements being the name and the desc, and the next ones being the application-names)
# ------------------------------------------------------------ %Struct = (); open (IN, "Abnova_Product_List.txt"); while(<IN>) { chomp($_); ($Key,$Name,$Desc,$OneApp) = split(/\t/,$_); if (! exists $Struct{$Key}) { $refArray = [$Name,$Desc,$OneApp]; $Struct{$Key} = $refArray; } else { $refArray = $Struct{$Key}; push (@$refArray,$OneApp); } } close(IN); open (OUT, ">Abnova_Products.txt"); foreach $Key (keys %Struct) { $refArray = $Struct{$Key}; print OUT "K=$Key\t".join("\t",@$refArray)."\n"; } close (OUT);
There are no "my" are they yours ????
Enjoy ;-)

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (4)
As of 2024-03-19 07:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found