in reply to Multidimensional array of hashes

Because your data files are very simple, only one hash table is required to hold the industry lookup. I have written a quick and simple code to do what you described. Keep the script simple and straight forward.
use strict; use IO::File; my %industries; # Load the industry definition file my $def = new IO::File "def.txt", "r" or die "Can not open file!"; while (<$def>) { if (m/'(.*?)','(.*?)'/) { $industries{$1} = $2; } } undef $def; # close the file # Load the data file my $dat = new IO::File "dat.txt", "r" or die "Can not open file!"; while (<$dat>) { s/('.*?'),('.*?')/$2,$1/g; # swap the items my $id = substr($_, 1, 2); print "'$id','$industries{$id}'|$_"; } undef $dat;
The input files are -
-- def.txt -- 'BB','Drinks Industry' 'BL','Construction Industry' -- dat.txt -- 'Coffee Suppliers','BB100'|'Tea Suppliers','BB106' 'Plasterers','BL100'|'Fencing Companies','BL102'
And the output is -
'BB','Drinks Industry'|'BB100','Coffee Suppliers'|'BB106','Tea Supplie +rs' 'BL','Construction Industry'|'BL100','Plasterers'|'BL102','Fencing Com +panies'
Cheers. Roger