in reply to What is wrong in this code?

Do not initialize your $max_number:

my $max_number; #initialize a variable that keeps the maximum n +umber

so you can check for undef in your loop:

if(!defined($max_number) or $current_number > $max_number) + { $max_number = $current_number; #compare each time t +he number we have in the line with the max number }

Replies are listed 'Best First'.
Re^2: What is wrong in this code?
by Anonymous Monk on Feb 13, 2014 at 15:11 UTC
    syntax error at myscript.pl line 3, near "=;"
    It's the line with my $max_number;

      Just remove the = sign.