Tags,Marker,Description,Currency,Industry,SuperSector,Sector,Sub Currencies FWA,WORLDS,World Index,USD,0001|1000,,0530|1770, FBRIC,AWBAX,All-World BRIC Index,USD,,,, FWBRA,WIBRE,Brazil Index,USD|9LC #### { 'SectorCurrency' => '', 'Currency' => 'USD', 'SourceID' => 'WORLDS', 'Name' => 'World Index', 'ExchangeTag' => 'FWA' }; { 'SectorCurrency' => '', 'Currency' => 'USD', 'SourceID' => 'WORLDS', 'IndustryCode' => '0001', 'Name' => 'FTSE World Index', 'ExchangeTag' => 'FWA0001' }; { 'SectorCurrency' => '', 'Currency' => 'USD', 'SourceID' => 'WORLDS', 'IndustryCode' => '1000', 'Name' => 'FTSE World Index', 'ExchangeTag' => 'FWA1000' }; { 'SectorCurrency' => '', 'SectorCode' => '0530', 'Currency' => 'USD', 'SourceID' => 'WORLDS', 'Name' => 'FTSE World Index', 'ExchangeTag' => 'FWA0530' }; { 'SectorCurrency' => '', 'SectorCode' => '1770', 'Currency' => 'USD', 'SourceID' => 'WORLDS', 'Name' => 'FTSE World Index', 'ExchangeTag' => 'FWA1770' }; { 'SectorCurrency' => '', 'Currency' => 'USD', 'SourceID' => 'AWBRIC', 'Name' => 'FTSE All-World BRIC Index', 'ExchangeTag' => 'FBRIC' }; { 'SectorCurrency' => undef, 'Currency' => 'USD', 'SourceID' => 'WIBRA', 'Name' => 'FTSE Brazil Index', 'ExchangeTag' => 'FWBRA' }; { 'SectorCurrency' => undef, 'Currency' => '9LC', 'SourceID' => 'WIBRA', 'Name' => 'FTSE Brazil Index', 'ExchangeTag' => 'FWBRA_L' }; #### #!/bin/perl use strict; use warnings; my $cfg_file = "/tmp/Allcontrol.csv"; read_control($cfg_file); sub read_control { my ($cfg_file) = @_; ## This is a internal module to parse and giveout data as hashref my $ctrl_data = ImportData(); my @IndxData; foreach (keys %$ctrl_data){ my $ExchangeTag = $ctrl_data->{$_}->{Tag}; my $Marker = $ctrl_data->{$_}->{Marker}; my $Name = $ctrl_data->{$_}->{Name}; my $Currency = $ctrl_data->{$_}->{Currency}; my $Industry = $ctrl_data->{$_}->{Industry}; my $SuperSector = $ctrl_data->{$_}->{SuperSector}; my $Sector = $ctrl_data->{$_}->{Sector}; my $Ind_Sec_Curr= $ctrl_data->{$_}->{Sub Currencies}; # Parse single/multiple currencies if(defined $Currency){ my @Currency = split /\|/, $Currency; foreach my $corecurr (@Currency){ my $row = {}; my $curr = substr($corecurr, 0,1); $curr = substr($corecurr, 1,1) if($curr eq "9"); if($curr eq "U"){ $row->{ExchangeTag} = $ExchangeTag; }else { $row->{ExchangeTag} = $ExchangeTag . "_" . $curr; } $row->{Name} = $Name; $row->{Currency} = $corecurr; $row->{SectorCurrency} = $Ind_Sec_Curr; $row->{SourceID} = $Marker; push @IndxData, $row; } } #Parse single/multiple industries if (defined $Industry and $Industry ne ""){ my @industry = split /\|/, $Industry; foreach my $ind (@industry){ my $row = {}; $row->{Name} = $Name; $row->{Currency} = $Currency; $row->{SectorCurrency} = $Ind_Sec_Curr; $row->{IndustryCode} = $ind; $row->{SourceID} = $Marker; $row->{ExchangeTag} = $ExchangeTag . $ind; push @IndxData, $row; } } #Parse multiple/single Sectors if (defined $Sector and $Sector ne ""){ my @sector = split /\|/, $Sector; foreach my $sect (@sector){ my $row = {}; $row->{Name} = $Name; $row->{Currency} = $Currency; $row->{SectorCurrency} = $Ind_Sec_Curr; $row->{SectorCode} = $sect; $row->{SourceID} = $Marker; $row->{ExchangeTag} = $ExchangeTag . $sect; push @IndxData, $row; } } } die Dumper @IndxData; }