How to find the Minimum of Three Numbers in Perl - Step by Step Examples
How to find the Minimum of Three Numbers in Perl ?
Answer
To find the minimum of three numbers in Perl, you can use the `min` function from the List::Util module.
✐ Examples
1 Find Minimum of Three Numbers
In this example,
- We use the `use List::Util 'min';` statement to import the `min` function.
- We declare an array with the numbers to compare.
- We use the `min` function on the array to get the minimum.
Perl Program
use List::Util 'min';
my @nums = (5, 8, 3);
my $min_val = min @nums;
print "Minimum of three numbers is: $min_val\n";
Output
Minimum of three numbers is: 3
Summary
In this tutorial, we learned How to find the Minimum of Three Numbers in Perl language with well detailed examples.