in reply to Re: Differences between Perl 5.8 and Perl 5.18.2
in thread Differences between Perl 5.8 and Perl 5.18.2

Thank you for your prompt reply. The program is this one:
#!/usr/bin/perl -w $im_thinking_of=int(rand10); print "Pick a number:"; $guess=<STDIN>; chomp $guess; if ($guess>$im_thinking_of) { print "You guessed too high!\n"; } elsif ($guess < $im_thinking_of) { print "You guessed too low!\n"; } else { print "You got it right!\n"; }
I have the following errors:
Argument "rand10" isn't numeric in int at guess line 3
Furthermore, it always gives me the answer
You guessed too high!
It is like it never reads elsif or else. This is only one example. I have other programs that have mistakes as well and it is not even my code. When I say that I copy and paste them, I mean that I read them from the book and write them again identically in my text editor.

Replies are listed 'Best First'.
Re^3: Differences between Perl 5.8 and Perl 5.18.2
by toolic (Bishop) on Apr 20, 2015 at 20:34 UTC
    You transcribed at least one line incorrectly. Change:
    $im_thinking_of=int(rand10);

    to (space between rand and 10):

    $im_thinking_of=int(rand 10);

      Such a simple mistake in front of my eyes....! Thank you very much for your reply.
        Just one single character or letter makes the difference between a program that runs and one that does not even compile.

        You can make a typo or spelling mistake in a text, a mail or a post on the Internet and will probably still be understood. On a program, no typo allowed, zero tolerance, it will just not run most of the time (and it is even worse if it runs and does something else than what you wanted).

        Je suis Charlie.