1. Perl
  2. Operators
  3. Arithmetic operator
  4. here

Division operator "/" - Division of numbers

You can use the division operator "/" to divide numbers.

my $num3 = $num1/$num2;

This is an example that divides 3 by 5.

my $num = 3/5;

In Perl, even a small number of divisions can be done without being aware of the type.

my $num = 3.5/2.7;

The result of the division operator is returned as a decimal.

Seeking a quotient

If you want to find the quotient of division, divide and then use int function to extract only the integer part.

my $div_int = int(12/5);

Explanation of arithmetic operators

The division operator is one of the arithmetic operators. For a detailed explanation of arithmetic operators, see the Arithmetic Operators Explanation page.

Related Informatrion