Beefy Boxes and Bandwidth Generously Provided by pair Networks
Think about Loose Coupling
 
PerlMonks  

Re: I wrote some clever code - can the comment "defuse" it? (explanations)

by Aristotle (Chancellor)
on Jun 17, 2003 at 21:31 UTC ( [id://266649]=note: print w/replies, xml ) Need Help??


in reply to I wrote some clever code - can the comment "defuse" it?

After some CB conversation, I decided to add the following information.

First of all - ignore the $curr->[STYLE].":". style bit which is from elsewhere in the code and not relevant here.

Secondly, the following is how it works. Please try to work it out before reading this, otherwise you don't help me. :)

I'm using a hash slice and a join to create a property map for the letters. If @letter is qw(F o o comma b a are) then after the hash slice and join I get "LLLXLLL". The regex splits this into qw(LLL X LLL), which is what map iterates over. The length of each of those matches controls the number of elements spliced off the front of @letter.

Update: these are then joined together so @letter_seq ends up as ("F,o,o", "comma", "b,a,are").

Makeshifts last the longest.

Replies are listed 'Best First'.
Re: Re: I wrote some clever code - can the comment "defuse" it? (explanations)
by BrowserUk (Patriarch) on Jun 17, 2003 at 22:18 UTC

    Apart from that I think that using the block form of map would make it a whole lot more obvious which part of this is being iterated over, which I know you'll disagree with, possibly vehmently :), I think description of how it works in this post is infinitely more useful as a comment that the original.

    I tried (really hard) to understand the code without the original comment. I eventually gave up and read the comment, and frankly was none-the-wiser. Maybe in the context of the surrounding code it might have clarified more. Once I read your description here, I finally understood what the code was doing, and how it was doing it.

    On that basis, I would use the description from this post, including the update, in preference to the original.


    Examine what is said, not who speaks.
    "Efficiency is intelligent laziness." -David Dunham
    "When I'm working on a problem, I never think about beauty. I think only how to solve the problem. But when I have finished, if the solution is not beautiful, I know it is wrong." -Richard Buckminster Fuller


Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://266649]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chanting in the Monastery: (4)
As of 2024-04-19 05:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found