Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Comment on

( #3333=superdoc: print w/ replies, xml ) Need Help??
Thanks! I almost agreed with your first suggestion, until I remembered why I used "default" as the, um, default value for the delimiter option. It seemed a lot less likely that someone would actually need to use the word "default" as a column delimiter, and rather more likely that they might want to use a single space character -- not in the "magical" sense of split ' ' but rather in the literal sense of split / / -- and this entails that every time the user gives a delimiter on the command line, it should always be treated as a regex. This way you only get the "magical" split behavior when you don't supply the "-d regex" option, and you have the ability to split on single space if you want to.

As for your second point, it's true the code as originally posted could lead to an "out of memory" condition, if it got a very long stream of repeated lines. But I wanted an array that I could "pop" or "shift" off of in order to print a duplicate line only once. So to fix the possible memory consumption problem, instead of "pushing" onto the array every time there's a duplication, I just make sure the array never contains more than one element (and this happens to be the line that the user wants to see). That made the print statements a lot simpler too, which is nice.

Update: then again, after making that change to how I was using the "heldline" array, I finally realized that it doesn't have to be an array, which is exactly what you said. So I fixed it (and I thank you) again.


In reply to Re^2: col-uniq -- remove lines that match on selected column(s) by graff
in thread col-uniq -- remove lines that match on selected column(s) by graff

Title:
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!
  • 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
  • Outside of code tags, you may need to use entities for some characters:
            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?
    Username:
    Password:

    What's my password?
    Create A New User
    Chatterbox?
    and the web crawler heard nothing...

    How do I use this? | Other CB clients
    Other Users?
    Others wandering the Monastery: (10)
    As of 2014-07-24 11:47 GMT
    Sections?
    Information?
    Find Nodes?
    Leftovers?
      Voting Booth?

      My favorite superfluous repetitious redundant duplicative phrase is:









      Results (160 votes), past polls