Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

comment on

( [id://3333]=superdoc: print w/replies, xml ) Need Help??

I have just come across the first time in a very long while that I feel a need to comment a piece of code. It's the solution for a relatively simple task that I find turned out very natural - if unorthodox. The latter is the reason I wonder whether I'll be able to decipher its meaning in a few months from now.

So first of all, I ask you to take a look at these four lines. All you need to know is that @letter contains symbolic letter names (the Postscript letter names, if anyone's curious) and that %property consists of pairs of all possible letter names and a value of either L, D or X. (Depending on whether the symbolic name represents a letter, a digit or something else as per its Unicode properties.)

Please don't look too hard at the code if you can't figure it out. Read the comment and then look again. My question is - how much help is the comment?

my @letter_seq = map( $curr->[STYLE].":".join(',', splice @letter, 0, length), join('', @property{@letter}) =~ /\G(X|D+|L+)/g, );
The comment:

# to group together letter characters, and digit characters,
# and leave anything else as single symbols, the regex engine
# is run against a map of letter properties put in a
# string. each match on the map is as long as a slice of
# consecutive characters with that property in the array

Makeshifts last the longest.


In reply to I wrote some clever code - can the comment "defuse" it? by Aristotle

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 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?Last hourOther CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (6)
As of 2024-03-29 14:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found