Anonymous Monk has asked for the wisdom of the Perl Monks concerning the following question:
#!/usr/bin/perl -w my $max_number=''; #initialize a variable that keeps the maximu +m number my $current_number=''; #variable that will keep the number of eac +h line for comparison while (defined ($current_number=<STDIN>)) { chomp ($current_number); if($current_number > $max_number) { $max_number = $current_number; #compare each time t +he number we have in the line with the max number } } print "The maximum number of all in your file is: ".$max_number."\n";
Argument "" isn't numeric in numeric gt (>) at myscript.pl line 9, <ST +DIN> line 1.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: What is wrong in this code?
by Athanasius (Archbishop) on Feb 13, 2014 at 15:33 UTC | |
Re: What is wrong in this code?
by hdb (Monsignor) on Feb 13, 2014 at 15:07 UTC | |
by Anonymous Monk on Feb 13, 2014 at 15:11 UTC | |
by hdb (Monsignor) on Feb 13, 2014 at 15:14 UTC | |
Re: What is wrong in this code?
by toolic (Bishop) on Feb 13, 2014 at 15:05 UTC | |
by Anonymous Monk on Feb 13, 2014 at 15:08 UTC | |
by toolic (Bishop) on Feb 13, 2014 at 15:12 UTC | |
Re: What is wrong in this code?
by pajout (Curate) on Feb 13, 2014 at 15:12 UTC | |
by Anonymous Monk on Feb 13, 2014 at 15:14 UTC |