Hi Bob, There is a simple problem here ******************** The file is -->
TEST_CASE_FILE_PATH = ../testcases/CAT/ TEST_CASE_OUTPUT_PATH = ../testlogs/ SERVER_NAME = sunomcr ******************** $VAR1 = 'TEST_CASE_FILE_PATH'; $VAR2 = '../testcases/CAT/'; $VAR3 = 'SERVER_NAME'; $VAR4 = 'sunomcr'; $VAR5 = 'TEST_CASE_OUTPUT_PATH'; $VAR6 = '../testlogs/'; foreach $key (%hash_line) { print "$key => $hash_line{$key}\n";} The output is like this --> TEST_CASE_FILE_PATH => ../testcases/CAT/ ../testcases/CAT/ => SERVER_NAME => sunomcr sunomcr => TEST_CASE_OUTPUT_PATH => ../testlogs/ ../testlogs/ => It seems it takes all the elements in the list as the key. Regards Rajeev -----Original Message----- From: Bob Showalter [mailto:[EMAIL PROTECTED] Sent: Tuesday, September 23, 2003 8:56 PM To: 'Pandey Rajeev-A19514'; [EMAIL PROTECTED] Subject: RE: Need help on Hash Slices. !! Pandey Rajeev-A19514 wrote: > Hi, > > I have a list like > > @list = ( "key1: Vlan1 :0989\n" > "key2: Vlan2 :0989\n" > "key3: Vlan3 :0989\n" > "key4: Vlan4 :0989\n"); > > I wanted to make a hash with keys as key1, key2 , key3, key4. > > I want to write something like this : > ********************************************** > my @keys, @values, @key_to_value; > (@keys, @values) = map /(key\d+): (\w+).*?$/, @list; > @[EMAIL PROTECTED] = @values; > > But the problem is the map function just creates one list > i.e. @keys .. so I am not able to make the hash. > > ie .. I want to extract @keys and @values in one go and then > use the HASH SLICE to get the desired result. > > Can some one help me. The only this is I don't want to > extract @keys and @values separately. Since map is returning a list in the form key, value, key, value, ... you can just assign directly to a hash: my %key_to_value = map /(key\d+): (\w+)/, @list; -- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]