input_parse_and_output("Bill"); input_parse_and_output("Bond"); input_parse_and_output("Note"); # Subroutine has two arguments 1.Input file name 2. Output file directory 3. Output file name all of these are scalar sub input_parse_and_output{ foreach my $input_data_each_line(@input_data_in_array){ chomp($input_data_each_line); # if the current line not contatin cusip then program will move to next line next unless $input_data_each_line=~ /cusip/; next unless $input_data_each_line=~ /"securityType":"$_[0]"/; if(defined $input_data_each_line){ foreach my $output_header_names_temp(@output_header_names){ chomp($output_header_names_temp); if(defined $output_header_names_temp){ # regex to replace the double quotes to blank string #input_data_each_line=~ s/"//g; $input_data_each_line=~ /$output_header_names_temp:([\w\d\-\$\%\:\!\@\&\*\.]+)/; if(defined $1){ my $temp=$1; if($temp=~ /\:/){ # regex for get exact first ten charavtetr it can be digit or hyphen $temp=~ /^([\d\-]{10})/; print OUTPUT_FILE_WRITE "$1\t"; } else { print OUTPUT_FILE_WRITE "$1\t"; } } else { print OUTPUT_FILE_WRITE "NULL\t"; } } } print OUTPUT_FILE_WRITE "\n"; } } }