> Hi,

Howdy

> 
> 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.
> 

Soemthing like this perhaps?

++UNTESTED++

my %hsh;
for(@list) { 
        my($k,$v) = $_ =~ m/(^\w+\):(.*)/;
        $hsh{$k} = $v;
}

HTH

DMuey

> 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.
> 
> Regards
> Rajeev
> 
> -- 
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 

--
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to