$structure{0009400000}{0009400ENG}{0000000002}{Required}=1.00 $structure{0009400000}{0009400ENG}{0000000002}{Lot}=[362475] $structure{0009400000}{0009400ENG}{0000000002}{Issued}=[1.0] $structure{0009400000}{0009400ENG}{0000000002}{UnitCost}=[1.0] $structure{0009400000}{0009400ENG}{0000000002}{TotalCost}=[1.0] $structure{0009400000}{0009400MFG}{&NI4820}{Required}=1.0 $structure{0009400000}{0009400MFG}{1003505000}{Required}=1.0 $structure{0009400000}{0009400MFG}{3102517000}{3102517001}{Required}=100.00 $structure{0009400000}{0009400MFG}{3102517000}{3102517001}{Lot}=[358379 366268] $structure{0009400000}{0009400MFG}{3102517000}{3102517001}{Issued}=[50.0 50.0] $structure{0009400000}{0009400MFG}{3102517000}{3102517001}{UnitCost}=[0.4452 0.5558] $structure{0009400000}{0009400MFG}{3102517000}{3102517001}{TotalCost}=[22.26 27.84] #### #!/usr/bin/perl # use strict; use warnings; use File::Find; use Data::Dumper; use Data::Diver qw (DiveVal); my @extracted=; $extracted[$#extracted+1]="end"; my @currentpath=(); my $structure={}; foreach my $i (0..$#extracted) { my @list=split /;/, $extracted[$i]; my @list2=split /;/, $extracted[$i+1]; if ($list2[0] eq 'end') { last; } if ($list2[0] gt $list[0]) { push @currentpath,$list[1]; print "=====\n$i\n====\n"; } elsif ($list2[0] eq $list[0]) { my $temp=join( ':',@currentpath); $temp=join(':',$temp,$list[1]); my $required=join(":",$temp,"required"); my @req=split /:/,$required; print "$temp\n"; DiveVal($structure, @req)= $list[3]; } elsif ($list2[0] lt $list[0]) { my $temp=join( ':',@currentpath); $temp=join( ':',$temp,$list[1]); my $required=join(":",$temp,"required"); my @req=split /:/,$required; print "$temp\n"; DiveVal($structure,@req)= $list[3]; pop @currentpath; } } print Dumper($structure); __DATA__ 0;0009400000;MASTERPAK 22,S/N 9400;1.00;379040;1.00;; 1;0009400ENG;LABOR,ENG,MASTERPAK 22;1.00;379039;1.00;; 2;0000000002;REFERENCE INFORMATION;1.00;362475;1.00;0.0000;0.00 1;0009400MFG;MASTERPAK 22,S/N 9400;1.00;379038;1.00;; 2;&NI4820;;0.00;0;1.00;32.5000;32.50 2;1003505000;PUMP,CNTFGL,02.000"FLG;1.00;367879;1.00;5692.8200;5692.82 2;3102517000;NAMETAG,VLV/INST,BIOPHARM;70.00;371584;70.00;; 3;3102517001;TAG,BLANK,1.5"DIA X .038";100.00;358379;50.00;0.4452;22.26 3;3102517001;TAG,BLANK,1.5"DIA X .038";;366268;50.00;0.5568;27.84 3;3102517002;LABEL,CLEAR,1"W X .5"H;100.00;298010;100.00;0.0124;1.24 2;3102519000;NAMETAG,EQUIP COMPONENTS;20.00;371583;20.00;; 3;3102519001;LABEL,WHITE,3"W X 3.5"H;20.00;358124;20.00;1.0664;21.33