Yes, this is what I told you. They provide only short code snippets to show how to solve a specific problem, but usually don't give full programs. Because of that, they suppose that the variables have been declared earlier, it is up to you to do it (usually with the 'my' function) when you use the code snippets to write an actual full program.
In the case of the randcap program, you need to comment out the first line, because it is a comment, not a line of code.
Example of possible corrections to be made for the 1st program:
#!/usr/bin/perl use strict; use warnings; print "How old are you?"; my $age = <>; print "What is your favorite color?"; my $color = <>; print "You are $age, and your favorite color is $color.";
Just adding the "my" function for the two variables should remove your compile time errors.
In reply to Re: mail question and book, and code
by Laurent_R
in thread mail question and book
by Raymond
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |