The Template Toolkit language isn't really perl. It is primarily about text substitution, not computation. It's possible to embed real perl in a template with the PERL directive. Here's your code with that modification,
When run, that produces,#!/usr/bin/perl -w use strict; use Template; my $template=new Template( EVAL_PERL => 1); $template->process(\*DATA) || die $template->error; __DATA__ 8 and 1 = [% PERL %] print 8 & 1 [% END %] (should be 0, if we use a b +inary operator) 8 or 1 = [% PERL %] print 8 | 1 [% END %] (should be 9, if we use a bi +nary operator)
"Binary operator" usually refers to an op with two arguments, usually with infix semantics. We usually call the operators you wanted "bitwise". In perl, and and or are low-precedence versions of the logical operators && and ||.$ perl ttbin.pl 8 and 1 = 0 (should be 0, if we use a binary operator) 8 or 1 = 9 (should be 9, if we use a binary operator) $
After Compline,
Zaxo
In reply to Re: Template toolkit binary operations
by Zaxo
in thread Template toolkit binary operations
by nikos
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |