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

Re: For loop suggestions

by moritz (Cardinal)
on Jan 11, 2013 at 06:31 UTC ( #1012805=note: print w/replies, xml ) Need Help??

in reply to For loop suggestions

Hello sure_mp,

your question would be much more readable if you used a dot at the end of each sentence, and occasionally a paragraph.

As for the question: Instead looping from the minimum and the maximum value, simply loop over all the distinct values that you get from the database. For each number, check if it's 1 plus the previous number, and if yes, join them to a range.

Replies are listed 'Best First'.
Re^2: For loop suggestions
by sure_mp (Initiate) on Jan 11, 2013 at 08:58 UTC
    Thanks, will indent the code properly next time. I also though about looping through the hash but aren't hashes unordered so how do i get the "last element" inside a loop
      You can even format and indent the code you posted before. Please, do not hestitate to do so.
      لսႽ ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1012805]
[erix]: to use anchors in a html table., how do I do that?
[erix]: I'm pretty sure I've done that before but I can't seem to get it right at the moment...

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (8)
As of 2018-06-19 12:25 GMT
Find Nodes?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?

    Results (113 votes). Check out past polls.