There’s a third alternative using
uc :
#23456789_123456789_123456789_123456789_12
perl -nlE'65^unpack"%c*","?"x30&uc or say'
Those spaces around
or are annoying... Let's use something else to express conditionnal printing. With -p, x= does the job:
#23456789_123456789_123456789_123456789_1
perl -ple'$_ x=65==unpack"%c*","?"x30&uc'
While we're looking at those switches... Why the -l? Removing it and adding
ord("\n") (10) to the target (65) shaves another stroke:
#23456789_123456789_123456789_123456789_
perl -pe'$_ x=75=~unpack"%c*","?"x30&uc'
There's a much shorter solution using a 6-bit checksum. The problem is that it comes up with a few false positives (words whose value is 1, 129, 193...):
#23456789_123456789_123456789_1234
perl -ple'$_ x=1==unpack"%6c*",uc'
perl -pe'$_ x=11==unpack"%6c*",uc'
Using a 5-bit checksum removes the need for
uc, but brings even more false positives:
#23456789_123456789_123456789_1
perl -ple'$_ x=1==unpack"%5c*"'
perl -pe'$_ x=11==unpack"%5c*"'
perl -nlE'1^unpack"%5c*"or say'
perl -nE'11^unpack"%5c*"or say'
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.