Beefy Boxes and Bandwidth Generously Provided by pair Networks
Problems? Is your data what you think it is?
 
PerlMonks  

comment on

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

It's not just terseness, it's also that the pieces in Perl fit together. In many other languages I use, I end up with clunky constructs because, for example, a particular statement doesn't evaluate its arguments, and there's no magic "yes, do it now" switch.

Case in point: some code I wrote today has to rewrite a SQL template based on data returned from another query. I have to form a comma-separated list of the values in the first column of the result set, and I need to preserve the original template. (It's an SQL in clause; before I get brow-beaten, I should mention I'm working under "sociological" restrictions.)

Here's what I wrote (paraphrased): ($sql = $templ) =~ s/#LIST#/join ',', map { $_->[0] } @res/e;It's not golf, it's just a nice fit.

I'd be willing to type longer strings to get this, but the fact that I can feed map to join and use it on the RHS of a substitution makes me smile! I shudder to think what I'd have to do to achieve the same thing in, say, VBScript (to pick a particularly nasty example).


In reply to Re: Compactness by VSarkiss
in thread Compactness by FoxtrotUniform

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 contemplating the Monastery: (6)
As of 2024-03-28 19:30 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found