Perform calculations
  1. Create a new script with this code:

    #!/usr/bin/perl
    print "Content-Type: text/html \n\n";

    $var1 = 5;
    $var2 = 2;

    $answer = $var1 + $var2 ;

    print "$var1 plus $var2 equals $answer.\n";
  2. Save the script as add.pl in the PERLSCRIPTS folder.

    Here's what the relevant lines in this script do:
  • $answer = $var1 + $var2 ;

    Adds the scalar variables $var1 and $var2 together, then assigns the sum to a scalar variable called $answer.

    Since $var1 is 5, and $var2 is 2, $answer has a value of 7.

  1. Upload add.pl to the perlscripts directory on the Web server, then set its permissions so that anyone can execute it.