in reply to get next higher number

Is this a homework question? If so, you should tell us that. You will still get help and we will understand how to better help you.

If this is not a homework question: Where do these numbers come from? What do they represent? How many numbers could there be? What is the maximum range of the numbers? How important is speed of calculation vs storage space? - Yes, that is a complicated question, but this is a common programming tradeoff. Knowing the answers to those basic questions and the overall context of your application would, with a high probability, lead to a more efficient solution and a "better" answer.

You wrote; "I prefer not to use any other functions or modules." Well, if(looks_like_number($row) calls a function that is not shown in your code.

Update: I don't see any Print statement in the original code. If there is no output, then any calculations are meaningless.

Replies are listed 'Best First'.
Re^2: get next higher number
by AnomalousMonk (Archbishop) on Jun 11, 2018 at 22:16 UTC

    "I prefer not to use any other functions or modules."   Yes, this does carry the stink of homework.


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

      Nope its a task I was given at work. `looks_like_number` is already used a function in the code so I can use it, but *prefer not to add additional modules and functions* so I won't need to install them.
      P.S which university course teaches Perl in 2018?
      thank you for your time.