Homework 1

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

Exercise 1

Allow the user to input a number on the command line that represents the radius of a circle.Do not use the <>. Print the user input. Then, compute the circumference of the circle as 2*pi*r. Let pi=3.14159. Print out the result as just the number. Separate these lines with a line break. For example, if the user inputs 0.5, your program should output the following:
0.5
3.14159
Do not include any other text in your output or else your code will not receive credit.

Exercise 2

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 5. Add only ONE line of code, and you must use the variable $x and do some math to get to the value of 5 that is printed.

Exercise 3

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 (i.e. when they run the program they will type "perl ex3.pl mypassword") , and you have to see if it is correct. Print "Access Granted" if the password is correct. If the password is incorrect, print "Access Denied".

Assume the correct password is "larrywall" without the quotes.

Exercise 4

Do not turn this in online. Hand write the honor code, sign it, and bring it to class next time.