josh803316 has asked for the wisdom of the Perl Monks concerning the following question:
cmd>statistics standard summary result>ORIG ATTMPT ORIG COMPL TERM ATTMPT TERM COMPL + Summary 2555 2543 2543 2543
So, after all that, I guess my question is, what is the best way to use JSON.pm (JSON::XS backend) to allow for encoding and decoding of these strings while maintaining the correct structure for regex escaping, etc..?#Inline Perl [% PERL %] my $result = $stash->get('result'); my ($orig_attmpt, $orig_compl, $term_attmpt, $term_compl) = ($result + =~ /Summary.*(\d)\s+(\d)\s+(\d)\s+(\d)/ ); if (($orig_compl/$orig_attmpt) > 0.95) { print 1; } else { print 0; +} [% END %] OR #More Advanced Template [% matches = result.match('Summary\s+(\d)\s+(\d)\s+(\d)\s+(\d)') %] [% IF match.2/match.1 > 0.95 %]1[% ELSE %]0[% END %]
BEGIN { $ENV{PERL_JSON_BACKEND} = 2 } # with JSON::XS use JSON qw( -support_by_pp -convert_blessed_universally ); my $json = new JSON; $json->allow_nonref->allow_blessed->convert_blessed->loose;
|
|---|