in reply to What is wrong in this code?

Initialize your $max_number to the minimum value you expect. For example, if you only expect positive numbers, set it to 0:
my $max_number=0; #initialize a variable that keeps the maximum + number

Another approach is to store all values into an array, then use List::Util max . This assumes memory is not an issue.

Replies are listed 'Best First'.
Re^2: What is wrong in this code?
by Anonymous Monk on Feb 13, 2014 at 15:08 UTC
    Yeah, thing is that the file can contain both, so what can I do in this case?
    (but not use Perl modules which is the obvious solution)
      but not use Perl modules
      List::Util is a Core module, so there is no need to install it.