Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??

The blog post is a really interesting, and it shows something important about the programming ability of the writer.

The original Perl code worked, but it was a little clumsy. A visitor called Gavin wrote, essentially, a two liner out of it, then relented and wrote a cleaner version that was 15 lines long. But there were important differences between that version and the original Perl solution.

In the original solution, contact records were only discarded near the very end of the script, when in fact they could be discarded during the input loop. This would have saved storing and sorting unwanted records, and this is true in any language.

Similarly, in the original code, each record was extracted into an array, then a reference to that array was pushed into another array -- a named variable was created each time around the loop. It would have been more efficient to wrap the statement in square brackets and make it an anonymous array, which is what Gavin's solution did. it seems obvious -- if you're creating a variable inside a small scope and using it just once, why is it there at all?

Our own blazar (I presume) produces a very readable solution that is somewhat terse but very compact. brainspun produces a nice version but again it misses the point of filtering out unwanted records in the input loop.

There's even a great shell solution which is actually what I thought about the first time I read the blog. It's a very clean way of solving the problem, and that solution *does* check the 'contact me' bit first.

Great find .. thanks!

Alex / talexb / Toronto

"Groklaw is the open-source mentality applied to legal research" ~ Linus Torvalds

In reply to Re: One Monasterian's Prodigal Journey by talexb
in thread One Monasterian's Prodigal Journey by bradcathey

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

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [LanX]: keep your sexlife private, please!
    [LanX]: ;-p
    shmem spent 3 hours chasing a bug related to variable scoping
    [shmem]: is there an equivalent to my in python? or 'use strict' ?
    [LanX]: I doubt
    [LanX]: only nonlocal in Py3
    [shmem]: so, python sucks
    LanX NSFW!!!

    How do I use this? | Other CB clients
    Other Users?
    Others making s'mores by the fire in the courtyard of the Monastery: (5)
    As of 2018-03-20 17:53 GMT
    Find Nodes?
      Voting Booth?
      When I think of a mole I think of:

      Results (256 votes). Check out past polls.