You can use the int function to retrieve the integer part of a number that includes a decimal point.
$ret = int $num;
The integer part is the part of the decimal point with the part after the decimal point removed. It is different from devaluation or rounding up. For example, if the decimal number is "1.5", the integer part is "1". If the decimal number is "-2.5", the integer part is "-2".
If you pass an integer, the integer will be returned as is.
This is an example to extract the integer part using the int function.
use strict; use warnings; my $num1 = 1.5; my $num2 = -1.5; print "(1) Extract the integer part.\n"; my $num1_int = int $num1; my $num2_int = int $num2; print "integer part of $num1: $num1_int\n"; print "integer part of $num2: $num2_int\n";