in reply to Differences between Perl 5.8 and Perl 5.18.2

Almost any program that runs under Perl 5.8 will still run on Perl 5.18, especially programs in a book for beginners (the opposite would not be true). There must be something that you are not doing right when typing or copying and pasting the source code. Please provide a verbatim example of a program that does not run on your computer.

One possible explanation is that the "shebang line" (something like #!/usr/bin/perl at the top of the program does not correspond to the place where Perl is installed on your computer. Try to type which perl at the shell prompt to check where Perl is installed.

Je suis Charlie.

Replies are listed 'Best First'.
Re^2: Differences between Perl 5.8 and Perl 5.18.2
by mbgbioinfo (Novice) on Apr 20, 2015 at 20:27 UTC
    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.
      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.