###Reading layout while (<$CONFIG>){ chomp; my @list=split(/$hash_ref->{DELIMITER}/); $file_list = $list[1]; $file_list =~ s/CCYYMMDD/$date/g; push @{$look_info{$list[0]}},$file_list."-".$list[2]."-".$list[3]; push (@header, $list[0]); } ###reading data file while (<$SRC_FILE>){ @data=split(/$hash_ref->{DELIMITER}/,$_); while ( ( my $column) = each %look_info){ foreach my $pos_info (@{$look_info{$column}}){ @look_here = split(/\-/, $pos_info); #print "look here : @look_here \n"; $lkp_file_name = $look_here[0]; $key_location = $look_here[1]; $data_location = $look_here[2]; $key_string = $data[$key_location-1] ; chomp $key_string; print "key_string : $key_string \n"; my $key_pattern = "|".$key_string."|"; #print "key string is : $key_pattern \n"; $final_data = ` grep "$key_pattern" "${indir}/${lkp_file_name}" |cut -d"|" -f"$data_location"`; #print "data value is : $final_data \n"; chomp $final_data; push @{$final_record{$column}},$final_data."|"; } } } ###printing final file my $i =0; my @currdata; $headerstring = join('|', @header); print $OUTPUT_FILE $headerstring."\n"; while(1){ foreach my $head (@header){ chomp $head; $head =~ s/\\//g; @currdata = @{$final_record{$head}}; print $OUTPUT_FILE "$currdata[$i]"; } print $OUTPUT_FILE "\n"; $i++; if ($i>($#currdata)){ last; } }