Beefy Boxes and Bandwidth Generously Provided by pair Networks
laziness, impatience, and hubris
 
PerlMonks  

comment on

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

Some comments:

  • In your code here, an input part number group item is treated as a subset of another group only if it is anchored at the left end of the larger group. E.g., the items  7K3377|3H5788 8W1152 4P0489|2757803 added to the list of test input data will not be excluded from output, but, of course,  2N0472|6N8595 2N0472 will be.

    In the OPed code, the if-block
        if ($strChain ne $_ && index($_, $strChain) >= 0) { $found = true;  last; }
    implies that a part number group is a subset if it is found anywhere (per the  >= comparison) in the larger group (and is not identical to the larger group).

  • Additionally, the OPed code implies that duplicated items in the input appear unchanged in the output (if they are not part of any larger group), e.g.,  123 ... 123 in the input would appear as  123 ... 123 in the output. In your code, these items would be made unique.
  • Also, the OPed code would produce output in the same order as the input items (less subsets), although this implied requirement seems less imperative than the others. Because it's taken directly from a hash, your code will produce output in random order.


Give a man a fish:  <%-{-{-{-<


In reply to Re^2: Best method to eliminate substrings from array by AnomalousMonk
in thread Best method to eliminate substrings from array by catemp

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 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? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (1)
As of 2022-07-06 04:02 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found

    Notices?