Fellow monks,
I'm in the middle of a project and I've run into a small problem in trying to keep strict.

I have a bitmask which is related to tests to be run. The easiest way I've determined to do this is, if the bit is set, run the test, but i do this with an object function call from the var. I know otherways around this, but I'm looking for effciency. And I don't know that 16 if statements are better then using "no strict refs;".

Here's what I'm talking about, keep in mind I have to add "no strict refs" to the module code in order for it to work this way.
use strict; my %byte; my $mask = "267"; #example my @tests = ("test0", "test1", "test2", "test3", "test4", "test5", "test6", "test7", "test8"); @byte{@tests}= map { 1<<$_ } 0..8; #props to tye foreach my $test (@tests){ if($mask & $byte{$test}){ $mask = $mask ^ $byte{$test} unless $t->$test(); #if the test returned false we unset the bit } }
So, in your opinion, is there a better way to do this and still keep strict?

In reply to Function refs, and trying to keep strict by jaco

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.