To find the maximum of two numbers in Perl, you can use the max function from the List::Util module.
In this example,
use List::Util qw(max);
statement to import the max function.$a
and $b
and assign values to them.max
function to find the maximum of $a
and $b
.# Maximum of Two Numbers
use strict;
use warnings;
use List::Util qw(max);
my $a = 10;
my $b = 15;
my $max_value = max($a, $b);
print "Maximum of $a and $b is: $max_value\n";
Maximum of 10 and 15 is: 15
In this tutorial, we learned How to find the Maximum of Two Numbers in Perl language with well detailed examples.