Please find the attachment. On Thu, Dec 17, 2015 at 1:26 AM, Raj Barath <barat...@outlook.com> wrote:
> 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> wrote: > >> ++Subject & Thanks. >> >> On Thu, Dec 17, 2015 at 1:08 AM, perl kamal <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 ; >>> >> >>
LIST DATSOURCES { "outcome" => "success", "result" => { "data-source" => { "PayrollTransferUserDataSource" => undefined, "ReportingDataSource" => undefined, "ReportingTransferUserDataSource" => undefined, "PayrollDataSource" => undefined, "PayrollServicesDS" => undefined }, "jdbc-driver" => {"oracle" => undefined}, "xa-data-source" => undefined } } Test Datasoure Connection Test:PayrollDataSource { "outcome" => "success", "result" => [true] } Test:ReportingTransferUserDataSource { "outcome" => "success", "result" => [true] } Test:ReportingDataSource { "outcome" => "failed", "failure-description" => "JBAS010440: failed to invoke operation: JBAS010447: Connection is not valid", "rolled-back" => true } Test:PayrollTransferUserDataSource { "outcome" => "success", "result" => [true] } Test:PayrollServicesDS { "outcome" => "success", "result" => [true] } Stats For PayrollServicesDS { "outcome" => "success", "result" => { "allocation-retry" => undefined, "idle-timeout-minutes" => 15L, "jndi-name" => "java:jboss/datasources/PayrollServicesDS", "jta" => true, "max-pool-size" => 150, "min-pool-size" => 15, "new-connection-sql" => undefined, } } Stats For PayrollTransferUserDataSource { "outcome" => "success", "result" => { "allocation-retry" => undefined, "idle-timeout-minutes" => 15L, "jndi-name" => "java:jboss/datasources/PayrollTransferUserDataSource", "jta" => true, "max-pool-size" => 30, "min-pool-size" => 1, "new-connection-sql" => undefined, } } Stats For PayrollDatasource { "outcome" => "success", "result" => { "allocation-retry" => undefined, "idle-timeout-minutes" => 15L, "jndi-name" => "java:jboss/datasources/PayrollDataSource", "jta" => true, "max-pool-size" => 45, "min-pool-size" => 15, "new-connection-sql" => undefined, } } Stats For ReportingDataSource { "outcome" => "success", "result" => { "allocation-retry" => undefined, "idle-timeout-minutes" => 15L, "jndi-name" => "java:jboss/datasources/ReportingDataSource", "jta" => true, "max-pool-size" => 25, "min-pool-size" => 10, "new-connection-sql" => undefined, } } Stats For ReportingTransferUserDataSource { "outcome" => "success", "result" => { "allocation-retry" => undefined, "idle-timeout-minutes" => 15L, "jndi-name" => "java:jboss/datasources/ReportingTransferUserDataSource", "jta" => true, "max-pool-size" => 30, "min-pool-size" => 1, "new-connection-sql" => "BEGIN PXSEC.CA_CLTXFER_ROLE_PROC; END;", } }
-- To unsubscribe, e-mail: beginners-unsubscr...@perl.org For additional commands, e-mail: beginners-h...@perl.org http://learn.perl.org/