Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Interesting that my last modification timed out. Did you run it with $i or $i+1?

Exactly as you posted it (c&p).

I just added print "i:$i j:$j"; to the bottom of the loop and it shows what happens:

i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 i:1 j:1 ...

Your concern about my use of $i+1 ignores the difference in the relative ordering of the ++$i increment in my version and yours. (The original.)

And your addition of the if statement never avoids the need to perform the index, so is pure overhead.

As for the possibility of out-by-one errors:

I'll trade the need to fix them, for the ability to make them; when the alternative is to rely upon the (unseen, unknown, uncontrollable, and possibly non-existent) generic optimisations of a declarative tool to convert a high-level -- and potentially completely broken -- abstract description of my problem into an efficient solution.

Had I opted for that approach, I would have settled on Damian's original solution. There would have been no incentive for him to improve it; or you to correct and improve yours.

The result would have been that my application for this; currently running on one of my 4 cores and projected to run for 7 to 10 days; would have projected to run for 143 1110 years! In other words, it would have been abandoned.

Far too often people settle for the first solution on offer -- cpan -- and never consider the affect their choices have.

So yes, I'll willingly trade the need to correct out-by-one errors; for the ability to make them in the first place.

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

In reply to Re^10: Finding repeat sequences. by BrowserUk
in thread Finding repeat sequences. by BrowserUk

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
    and all is quiet...

    How do I use this? | Other CB clients
    Other Users?
    Others taking refuge in the Monastery: (11)
    As of 2017-12-18 13:17 GMT
    Find Nodes?
      Voting Booth?
      What programming language do you hate the most?

      Results (485 votes). Check out past polls.