Perl - Part 7
[home] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25]
Program Line Types
All lines in a Perl program are either:- Blank lines, for appearance.
- Comment lines - for our benefit - giving an internal explanation of the program functions, Author etc. These lines start with a # and a space.
- Program or Directive lines. The most common (or only) directive line is #!/usr/bin/perl at the very start of each file. Normal program lines are written in Perl.
- Program lines should be indented, again for appearance. Indent consistently by one or by two spaces.
- This tidy appearance can pay major dividends in a larger program when you're fault finding.
- When you start to add program-flow control instructions you'll indent further again, but by the same number of spaces that you've already chosen.
Task 003
This task again comes with a specification, as well as sample (but completely unnacceptably unfriendly) output. Specification:- Create a file called multy01.pl
- This program should first display your name and one clear blank line before commencing proper.
- The program should prompt the user to enter 3 numbers
- The program should then request and accept each number in turn
- Once all three numbers have been accepted the program should calculate the product (multiply!) the three numbers
- The product should be displayed with suitable explanatory text
- One clear line should be displayed at the program end before the command prompt appears
- Internally the program should have comment lines to indicate Author, Date, Task & Purpose. These comments should not prevent the line #!/usr/bin/perl from being the very first line in the program as this would most likely cause errors.

# # ---------------------------------------------------------------------------------- # Author: Fachtna Roe Date: 20061206 # Title: multy01.pl Purpose: To prompt for and # to accept three numbers, then to output # the product of the numbers. # ---------------------------------------------------------------------------------- #Further challenges lie ahead......
[home] [1] [2] [3] [4] [5] [6] [7] [8] [9] [10] [11] [12] [13] [14] [15] [16] [17] [18] [19] [20] [21] [22] [23] [24] [25]
Last updated: 20131015-16:45