Question: Here are the requirements for this assignment: 1. Using Bluefish, create a Perl script named myscript.pl in your Working Directory. 2. Write some code in
Here are the requirements for this assignment:
1. Using Bluefish, create a Perl script named myscript.pl in your "Working Directory".
2. Write some code in myscript.pl that will create an array.
3. Populate 10 elements of the array with the numbers 1 through 10.
4. Add all of the numbers contained in the array.
5. Output the total number to the screen, like this: The total is: $myTotal where $myTotal is the variable containing your total (the just moves the cursor to the next line).
Hint #1: Use a loop to add the numbers from the array. There is a particular kind of loop specifically meant for "walking" an array in Perl. Hint #2: Some languages echo, while others print. Hint #3: If Perl gives you an error about a variable not being initialized, that means you attempted to use it before you assigned a default value (like "" for strings, or 0 for numbers) to it. Hint #4: Make sure to include your interpreter line at the top of your script: #!/usr/bin/env perl Hint #5: Place the use strict and use warnings commands directly below your interpreter line. These will help you code, by generating more meaningful error messages.
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
