Search code examples
perloperatorsassignment-operatorequality-operator

Difference between == , = and eq


I want to know the difference between these:

 my $a = 1;

and

 my $a == 1;

and

 my $a eq 1;

Solution

  • == is used when comparing numeric values.

    eq is used in comparing string values.

    = is the assignment operator, not a comparison operator.