"be consistent" PerlMonks

### Comment on

 Need Help??

Did you know you could evaluate a polynomial over GF(128) in perl with pack and unpack and tr? Here's how.

```sub h {
\$_ = \$_[0] = pack b208, 0 . unpack b362, \$_[0];
tr/\0-\c?/\0/;
tr/\0/\377/c;
\$_
}
for (split //, "k6sNP2B}({ambrusLB%Ox)Z]n0*zf\0I3") {
\$y = \$r;
\$v = join \$r = '', a .. z;
\$r ^= h(\$r) & "\217" x 26 ^ h(\$v) & \$y for 0 .. 6;
\$r ^= \$_ x 26;
}
print \$r;

This code is based on the same idea as Dollar Plus, but written in a different style, so some of the credit goes to martin.

Update: if you prefer one of these unreadable blocks of code, you can of course write this that way too (Update: reformatted blob from four lines to three.)

```sub h(\$){(\$_=\$_[0]=pack b208,0 .unpack b362,\$_[0])=~tr/\0-\c?/\0/;tr
/\0/\377/c;\$_}do{\$y=\$r;\$v=join\$r='',a..z;\$r^=h\$r&"\217"x26^h\$v&\$y for
0..6;\$r^=\$_ x26}for"k6sNP2B}({ambrusLB%Ox)Z]n0*zf\0I3"=~/./g;print\$r

Update: removed lots of spaces from end of lines of formatted code.

In reply to Japh algebra, GF(128) edition by ambrus

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.
• Posts may use any of the Perl Monks Approved HTML tags:
a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, 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, 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: & & < < > > [ [ ] ]
• Link using PerlMonks shortcuts! What shortcuts can I use for linking?

Create A New User
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2018-04-26 08:29 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My travels bear the most uncanny semblance to ...

Results (95 votes). Check out past polls.

Notices?