Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
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'

In reply to Re^3: Homework Golf (35) by Grimy
in thread Homework Golf by McD

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



  • 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 or How to display code and escape characters are good places to start.
Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others contemplating the Monastery: (2)
As of 2021-08-03 16:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My primary motivation for participating at PerlMonks is: (Choices in context)








    Results (39 votes). Check out past polls.

    Notices?