2.3.1 Implicit Block of Statements
Let us look at a very simple program that converts a temperature from Fahrenheit to Celsius.
Program 2.7
#!/usr/bin/perl
#file temp1.pl
use strict vars;
my ($fahrenheit, $celsius);
$fahrenheit = 50;
$celsius = 5/9 * ($fahrenheit - 32);
printf "%4.0fF = %6.1fC\n", $fahrenheit, $celsius;
The program is simple. It has very few lines of code. A program is an implicit block. The statements in an implicit block are executed in sequence unless dictated otherwise by the code. An implicit block is usually delimited by the extent of a file. In this example, the whole program is in a file called temp1.pl, and everything contained in this file is an implicit block. Variables declared with my are available in the current block only, in this case, the extent of the file. The output of the program is given below.
50F = 10.0C
