Example 11 - Function definition.


#!/usr/bin/perl
#*********************************************************
# Example eleven - a basic function definition.
#           by Al Bento
#*********************************************************

#define variables

$f = 75;
$celsius = &convert;

# print conversion results

print " Fahrenheit Celsius\n";
printf "%6d %8d\n", $f, $celsius;

#*********************************************************

#sub definition

sub convert {
      $c = 5/9 * ($f-32);
}

download the script


This page is maintained by Al Bento who can be reached at abento@ubmail.ubalt.edu. This page was last updated on February 15, 2001. Although we will attempt to keep this information accurate, we can not guarantee the accuracy of the information provided.