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: > >> On Thu, Nov 15, 2012 at 2:46 AM, jet speed >> > ... >> > I was able to build the hash, however the file contains approx 10,000 >> > entries. but while i print the hash i get only approx 1300 lines or >> > key=>values. >> > >> > i guess its because, the file has duplicate entries. example below >> > >> > 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 >> > >> > How do i build all the entries into hash including the duplicates on >> both >> > sides keys and values. >> >> One possible way: >> >> DB_File has a BTREE file type (with the R_DUP setting and >> the 'seq' API method) that enables storing/retrieving dup's. >> There's a full example in the docs. >> >> See: perldoc DB_File. >> >> -- >> Charles DeRykus >> > > > 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 Appreciate all your inputs. Thanks Sj