Apr 252010
eq vs == in Perl
Answer:
1. eq
It perform string comparison.
my $foo = "123";
my $bar = "123";
print $foo eq $bar; # output "1"
2. ==
It perform numeric comparison, string is first converted to numeric value before compare.
my $foo = "foo";
my $bar = "bar";
print $foo == $bar; # output "1", since 0 = 0 as strings are converted to 0 in both variables