On Nov 15, 2012, at 8:40 AM, jet speed wrote:

> On Thu, Nov 15, 2012 at 2:49 PM, jet speed <speedj...@googlemail.com> wrote:
> 
>> On Thu, Nov 15, 2012 at 11:43 AM, Charles DeRykus <dery...@gmail.com>wrote:
>> 

>> Thanks Charles,
>> 
>> What i am trying to do ?
>> I want to match the entries from file1.txt with file.txt, if matches then
>> print the key and value. some will have multiple entries as in the output.
>> 
>> 
>> required output
>> --------------------
>> 
>> 10.00.00.00.aa.56.9b.7a 22:5a
>> 10.00.00.00.aa.57.99.8a 22:5a
>> 10.00.00.00.aa.46.9b.33 32:9c
>> 10.00.00.00.aa.5a.9b.63 a2:cc
>> 10.00.00.00.aa.5a.9b.63 a5:cc
>> 10.00.00.00.aa.5a.9b.63 b2:cc
>> 
>> 
>> file1.txt
>> ------------
>> 
>>  10.00.00.00.aa.56.9b.7a
>>  10.00.00.00.aa.57.99.8a
>>  10.00.00.00.aa.46.9b.33
>>  10.00.00.00.aa.5a.9b.63
>> 
>> 
>> 
>>>  file.txt
>>>> ----------------
>>>> 
>>>   22:5a => 10.00.00.00.aa.56.9b.7a
>>>   22:5a => 10.00.00.00.aa.57.99.8a
>>>   32:9c => 10.00.00.00.aa.46.9b.33
>>>   a2:cc => 10.00.00.00.aa.5a.9b.63
>>>   a5:cc => 10.00.00.00.aa.5a.9b.63
>>>   b2:cc => 10.00.00.00.aa.5a.9b.63
>>>   b2:55 => 10.00.00.00.aa.5a.9b.d8
>> 
>> 
> Thanks All, i managed to achieve the task without hash in the end, due to
> duplicate key. value pairs

It is good that you solved your problem. However, I think that a hash could be 
used, but that you are using the wrong value for the key. If you are given the 
string '10.00.00.00.aa.56.9b.7a' and want to know that it is associated with 
the value '22:5a', then '10.00.00.00.aa.56.9b.7a' should be the key of the 
hash, and '22:5a' should be the value.



--
To unsubscribe, e-mail: beginners-unsubscr...@perl.org
For additional commands, e-mail: beginners-h...@perl.org
http://learn.perl.org/


Reply via email to