Can you share a simple of JSON file and from that let us know what you want to capture.
On Wed, Dec 16, 2015, 3:41 PM perl kamal <kamal.p...@gmail.com<mailto:kamal.p...@gmail.com>> wrote: ++Subject & Thanks. On Thu, Dec 17, 2015 at 1:08 AM, perl kamal <kamal.p...@gmail.com<mailto:kamal.p...@gmail.com>> wrote: Hi, I am trying to read a json output file,capture the required information, storing them in an array and format the output in a file. Please review my code and suggest me is there any way to construct the hash data structure and use them in the file format. Instead of this (shift @Data_Sources||''), can we use keys or values.of the hash. Thanks. use strict; use Data::Dumper; my $file = shift || 'input_file.txtt'; # Attachement my ($data_source,@Data_Sources,@Stat_Data_Sources,@Min_Data_Sources,@Main_Status,@Test_DB_Con_Status,@Min_Conns,@Max_Conns); open my $in, '<', "$file" or die $!; open(FIN_ADV, '>', '/tmp/JsonToTxt.txt') or die "Can't open the file:$!\n"; while (<$in>) { #Stats For PayrollServicesDS if ( $_ =~ /Stats\s+For\s+(.*)/) { $data_source = $1; push @Min_Data_Sources, $data_source; } push (@Data_Sources,$1) if (/Test\:(.*)/); if ( /Test\:(?:.*)/ .. / \"outcome\"/ ) { my $status = $1 if ($_ =~ /\"outcome\"\s+\=\>(.*)/) ; $status =~ s/[",]//g; push @Test_DB_Con_Status, ($status) if defined $status; } @Stat_Data_Sources = @Data_Sources ; next unless ($_ =~ /"max-pool-size" |"min-pool-size" /); if ($_ =~ /"max-pool-size"/) { my $max_value = $1 if ($_ =~ /.*\=\>(.*)/) ; $max_value =~ s/[",]//g; push @Max_Conns, $max_value; } if ($_ =~ /"min-pool-size"/) { my $min_value = $1 if ($_ =~ /.*\=\>(.*)/) ; $min_value =~ s/[",]//g; push @Min_Conns, $min_value; } } if(my $FORMAT_LINES_LEFT == 10) { print FIN_ADV_TOP "Data source Statistics\n"; } #Fin Adv Report format FIN_ADV_TOP = Page:@<<< $% . format FIN_ADV = =================================================================================== LIST DATSOURCES =================================================================================== @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ (shift @Data_Sources||'') =================================================================================== LIST DATSOURCES Test DatasourceConnection =================================================================================== @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ @<<<<<<<<<<<<<<<<<<<<<~~ (shift @Stat_Data_Sources),(shift @Test_DB_Con_Status||'') =================================================================================== Data source Statistics =================================================================================== NAME Min Connection Max Connection ------------------------------------------------------------------------------- @<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<~~ @|||||||||~~ @|||||||||~~ (shift @Min_Data_Sources||''),(shift @Min_Conns||''),(shift @Max_Conns||'') . select(FIN_ADV); $= = 37; #$^L = "\n"; write ;