lenti224 [~/perltest]>more calc2.pl #!/opt/local/bin/perl # rounding of calculations, scalar numbers # do not include commas or spaces in scalar numbers. # For exampe, 10000, not 10,000; 1234.567, not 1 234.567 print "Division of one number by another.\n"; print "\n"; #get two numbers print " What is the first number? "; chomp($num1 = ); print "What is the second number? "; chomp($num2 = ); print "\n"; #division and rounding to two digits past the decimal point $num3 = $num1 / $num2; $num3 = int($num3*100)/100; print "$num1 / $num2 = "; print $num3; print "\n"; exit; lenti225 [~/perltest]>perl calc2.pl Division of one number by another. What is the first number? 2 What is the second number? 3 2 / 3 = 0.66 =================================== lenti229 [~/perltest]>more calc3.pl #!/opt/local/bin/perl # better rounding of calculations print "Division of one number by another.\n"; print "\n"; #get two numbers print " What is the first number? "; chomp($num1 = ); print "What is the second number? "; chomp($num2 = ); print "\n"; #division and rounding to two digits past the decimal point $num3 = $num1 / $num2; $num3 = int($num3*100 + 0.5)/100; print "$num1 / $num2 = "; print $num3; print "\n"; exit; lenti230 [~/perltest]>perl calc3.pl Division of one number by another. What is the first number? 2 What is the second number? 3 2 / 3 = 0.67 lenti231 [~/perltest]> ================================== lenti235 [~/perltest]>more calc4.pl #!/opt/local/bin/perl # rounding, printing a list, printing local date and time print "\n"; print ""Division of one number by another.\n"; print "\n"; #get two numbers print " What is the first number? "; chomp($num1 = ); print "What is the second number? "; chomp($num2 = ); print "\n"; #division (and rounding to two digits past the decimal pt) $num3 = $num1 / $num2; $num3 = int($num3*100 + 0.5)/100; print "$num1 / $num2 = ", $num3, "\n"; #and end with the current local date and time print "\n", $time=localtime,"\n\n"; exit; lenti236 [~/perltest]>perl calc4.pl Division of one number by another. What is the first number? 2 What is the second number? 3 2 / 3 = 0.67 Tue May 14 10:37:04 2002 lenti237 [~/perltest]> =====================