Perl Programming/Exercise 2
A. Input from the keyboard
- Write a program which asks for a line of text to be entered on the keyboard, and then displays that text on screen.
- Modify the program to ask for 3 lines of text, and display them on one line with a | symbol between each input.
Input from the command-line
Write a program which you can call like so:
perl myscript.pl "Argument 1" "Argument 2" "Argument 3"
The program should take as many command-line arguments as are available, and display them on screen.
Input from a text file
Create a text file containing the following 3 lines:
This is line one This is line two This is line threes
Write a program which reads the file, and displays all the lines of text. Modify it so that the whole file is output on one line with | characters between each input.
Putting it all together
Using the program from exercise 1, write a program which takes three numbers as command-line arguments, and solves the quadratic equation where those numbers are the roots.
If no numbers are available from the command-line, prompt the user to type each number at the keyboard.
If the first command-line argument is -h or --help, display some instructions on how to use the program.