My question:

Is there any way to process python inside the PERL block or any plugin that
allows for a [% PYTHON %] block.

Do people use Inline::Python for this or is there another way?

[% PERL %]

my $result = $stash->get('result');

use Inline Python => <<'END_OF_PYTHON_CODE';
   def compute_result($result):
      # Do something here

   END_OF_PYTHON_CODE

[% END %]


I'm trying to allow support for the following logic in both python and perl

(Example string showing simulated voice call statistics)
"cmd>statistics standard summary
        ORIG  ATTMPT  ORIG   COMPL  TERM  ATTMPT  TERM   COMPL
Summary 12                  12                  12
  12"


[% PERL %]
my $result = $stash->get('result');
my ($orig_attmpt, $orig_compl, $term_attmpt, $term_compl) =  ( $result =~
/Summary\s+(\d+)\s+(\d+)\s+(\d+)\s+(\d+).*/ );
# Do some math calculations here to determine call percentage
# If the percentage is greater than 95% print 1, otherwise print 0
[% END %]
_______________________________________________
templates mailing list
templates@template-toolkit.org
http://mail.template-toolkit.org/mailman/listinfo/templates

Reply via email to