http://www.perlmonks.org?node_id=232919

waxmop has asked for the wisdom of the Perl Monks concerning the following question:

Why doesn't == test all objects? WHY?

Here's some perl mason code I've been wrestling with. I couldn't figure out what was the problem until I remembered that in perl, you gotta use 'eq' to compare strings.

<table> % foreach my $rec (@records) { % foreach my $k ( keys %ARGS ) { % if ( $ARGS{$k} ) {  <tr>   <td><% $rec->{$k} %></td><td><% $ARGS{$k} %></td> % if ( $ARGS{$k} eq $rec->{$k} ) {   <td>MATCH!</td> % }  </tr> % } % } % } </table>

Will this be changed in perl6? I really hope so. Python's == operator works great for all different sorts of objects. And ruby makes it super easy to overload every operator in the book. But not in perl! We gotta use a different comparison operator for different objects! GAHH!