I appologize because when I pasted this program into this page, it stripped most all of my indentation and visual organization :(

To Run Program:

1. Copy and paste this text into a file
2. Save the file
3. Set execute bit; ex: $> chmod u+x whateverFileName.pl

#Copyright Daniel Stickney 2001
#This program is free software; you can redistribute it and/or modify
#it under the terms of the GNU General Public License as published by
#the Free Software Foundation; either version 2 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#GNU General Public License is available if you write to the Free Software
#Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
#or at www.gnu.org.

#!/usr/bin/perl
# written in PERL v5.6.0
# exercise 3.14_d
# calculate the value of pi
print "Enter the number of loops used to calculate the value of pi\n";
$loops = ;
$inc = 3;
$pi = 4;
$on = 0;
for ($z = 1; $z <= $loops; $z++)
{
if ($on == 0)
{
$pi -= (4 / $inc);
$on = 1;
}
else
{
$pi += (4 / $inc);
$on = 0;
}
# print "\$inc = $inc, \$pi = $pi, \$on = $on \n";
# WITHOUT PRINTING IT CALCULATES SOOOO SOOO SOOOO MUCH FASTER
$inc += 2;
}
print "pi = $pi\n";