Perl Home Notes Exercises Resources perl Thoughts Jen's Home Summer Perl Seminar

Week 1 Exercises

Practice runing code, and debugging. Here are some specific things to test yourself. Soultions will be posted this weekend.

Exercise 1

Start with this program: #!/usr/bin/perl $x = 3; Now, add a line to the end so it will print: The value of $x is 3. Use the variable $x to print the 3 (don't just type the number 3 in your code).

Solution

Exercise 2

Remember that if the user types perl myCode.pl yo! You can get that yo! (or whatever value), by doing this: $input = @ARGV[0]; And that will store the value in a variable called $input.

Also remember that if you want to compare strings, you use eq for equals and ne for not equals.

Write a program that checks for a password. Expect that the user will type a password in as their argument, and you have to see if it is correct. Print a happy "Access Granted" type message if the password is correct, and an angry "go away evil doer" message if the password is incorrect.

The password is: succulent.

Solution