area_of_triangle.pl 412 B

123456789101112131415161718192021
  1. #!/usr/bin/perl
  2. # Author: Daniel "Trizen" Șuteu
  3. # License: GPLv3
  4. # Date: 17 August 2016
  5. # Website: https://github.com/trizen
  6. # Find the area of a triangle where all three sides are known, using Heron's Formula.
  7. use 5.010;
  8. use strict;
  9. use warnings;
  10. sub triangle_area {
  11. my ($x, $y, $z) = @_;
  12. my $s = ($x + $y + $z) / 2;
  13. sqrt($s * ($s - $x) * ($s - $y) * ($s - $z));
  14. }
  15. say triangle_area(5, 5, 6);