Hi Shawn, Thanks for the quick response. It works fine.
$temp = $ModelPath{"1"}; @Array = @$temp; # here I get the copy of "@one" into "@Array". But # can I directly get the copy of "@one" instead of having # it in two steps. Also is there a better way to define a hash when I already have existing arrays rather than defining the hash for every individual key and array. Thanks and Regards Suresh -----Original Message----- From: Shawn McKinley [mailto:[EMAIL PROTECTED] Sent: Wednesday, May 05, 2004 10:37 AM To: Suresh Pasupula (WT01 - EMBEDDED & PRODUCT ENGINEERING SOLUTIONS) Subject: RE: [ Hash of Arrays] Hey Suresh, Try something like this: <code> my @one = ("abc", "def"); my @two = ("ABC", "DEF"); my %ModelPath = {}; $ModelPath{"1"} = [EMAIL PROTECTED]; $ModelPath{"2"} = [EMAIL PROTECTED]; my $temp = $ModelPath{"1"}; # ^ not the use of $ instead of @ print '0: ',$temp->[0],$/, '1: ',$temp->[1],$/; # You are going to have to dereference # your temp var from this point forward # with the little arrow operator '->' </code> Shawn -----Original Message----- From: [EMAIL PROTECTED] [mailto:[EMAIL PROTECTED] Sent: Tuesday, May 04, 2004 11:58 PM To: [EMAIL PROTECTED] Subject: [ Hash of Arrays] Hi, I would like to initialize a hash of arrays and retrieve the contents of hash. For eg. I have two arrays. my @one = ("abc", "def"); my @two = ("ABC", "DEF"); Now I will initialize a hash in the following way. my %ModelPath = {}; $ModelPath{"1"} = [EMAIL PROTECTED]; $ModelPath{"2"} = [EMAIL PROTECTED]; When I retrieve the value from hash I have to do in the following way, if I am not wrong. my @temp = $ ModelPath{"1"}; #but here the temp[0] contains the whole array "one" rather than individual "$one[0]". Is there any other way to define a hash and retrieve the contents of it properly? Note: I don't want to define the hash of arrays in the following way: % ModelPath = { "1" => ["abc", "def"], "2" => ["ABC", "DEF"] }; As I want to use the already existing array in defining the hash. Please give ur comments. Thanks in advance Suresh Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. Confidentiality Notice The information contained in this electronic message and any attachments to this message are intended for the exclusive use of the addressee(s) and may contain confidential or privileged information. If you are not the intended recipient, please notify the sender at Wipro or [EMAIL PROTECTED] immediately and destroy all copies of this message and any attachments. -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED] <http://learn.perl.org/> <http://learn.perl.org/first-response>