How to find the Minimum of Two Numbers in Perl - Step by Step Examples
How to find the Minimum of Two Numbers in Perl ?
Answer
To find the minimum of two numbers in Perl, you can use the min function from the List::Util module.
✐ Examples
1 Minimum of Two Numbers
In this example,
- We use the
use List::Util qw(min);
statement to import themin
function. - We assign values to variables
$a
and$b
. - We use the
min
function to find the minimum of$a
and$b
. - We print the minimum value.
Perl Program
# Minimum of Two Numbers
use List::Util qw(min);
my $a = 10;
my $b = 15;
my $min_val = min($a, $b);
print "Minimum of $a and $b is: $min_val\n";
Output
Minimum of 10 and 15 is: 10
Summary
In this tutorial, we learned How to find the Minimum of Two Numbers in Perl language with well detailed examples.