Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

comment on

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

I was going to use a foreach loop, but the idiomatic code seemed (and now that I understand it, IS) better for maintainability, given that it hids indexing and is very concise

Obviously I needed to understand its workings before employing it en masse; now that it is clear to me I can say that these are the kind of things that make me love perl and I have a new nifty piece of syntax in my arsenal.

As for the $test variable, I agree that I could've chosen a better name (maybe $constraints like in the python original code). And given that it is just a one-off script made for fun, it is overkill to use a variable to hold the boolean, but I was influenced by habit (keep complex boolean conditions outside of the if) and by the over complex python code, where they actually create a function for every constraint and then put them in a tuple to map them to each permutation with all().

Thank you for your observations.


In reply to Re^2: Help me understand this idiomatic hash from array code by adhrain
in thread Help me understand this idiomatic hash from array code by adhrain

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 romping around the Monastery: (3)
As of 2024-04-20 00:08 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found