http://qs1969.pair.com?node_id=11140270


in reply to Parse file and creating hashes

I'm also not certain what you need, but here's what I pulled together from your description.

#!/usr/bin/perl use strict; use warnings; # 2022-0108: Read a CSV line w/ three elements, building a hash using # the third element and populated with the second element. use Data::Dumper; { my %hash; while (<DATA>) { s/\s+$//; my @w = split(/,/); push ( @{ $hash{ $w[2] } }, $w[1] ); } print Dumper ( \%hash ); } __DATA__ 702005010554291,5016554291,7020000023F22 702005010524898,5016524898,70200000441E0 702005010660208,5016660208,7020000033FD0 702005010509777,5016509777,7020000033FF0 702005010633781,5016633781,7020000024092 702005010616472,5016616472,7020000043FE2 310005010601516,5016601516,7020000044201 702005010526097,5016526097,7020000013EB1 702005010681238,5016681238,7020000044052 702005010551103,5016551103,7020000023F12 702005010625010,5016625010,7020000023F51
This produces the following results:
$VAR1 = { '7020000023F51' => [ '5016625010' ], '7020000044052' => [ '5016681238' ], '7020000033FD0' => [ '5016660208' ], '7020000044201' => [ '5016601516' ], '7020000023F22' => [ '5016554291' ], '7020000043FE2' => [ '5016616472' ], '7020000024092' => [ '5016633781' ], '7020000013EB1' => [ '5016526097' ], '7020000023F12' => [ '5016551103' ], '7020000033FF0' => [ '5016509777' ], '70200000441E0' => [ '5016524898' ] };

Let us know if this is what you wanted.

Alex / talexb / Toronto

Thanks PJ. We owe you so much. Groklaw -- RIP -- 2003 to 2013.