Please help me understand what I need to change in the beggining:
#!/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";

The error I get is:
Argument "" isn't numeric in numeric gt (>) at myscript.pl line 9, <ST +DIN> line 1.

The program works, but I think I did not set my $max_number=''; correctly... What should I put there?

In reply to What is wrong in this code? by Anonymous Monk

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.