Hi monks!

I've been using Template Toolkit for a while but still haven't figured out how to do bitwise operations in template-toolkit. [% 8 and 1 %] is 1 as it does a logical 'and' not bitwise. Same thing if I put '&&' (a logical operator). And it doesn't understand a bitwise operator '&' like in C. Is there any way to do bitwise calculations?

Just a short test code:
#!/usr/bin/perl -w use strict; use Template; my $template=new Template; $template->process(\*DATA) || die $template->error; __DATA__ 8 and 1 = [% 8 and 1 %] (should be 0, if we use a bitwise operator) 8 or 1 = [% 8 or 1 %] (should be 9, if we use a bitwise operator)


Thank you in advance.

Edited

In reply to Template toolkit binary operations by nikos

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.