Next | The Perl Hardware Store | DC.pm Version | 55 |
If $x and $y are references, you can compare them with ==:
$x == $y
This is true if and only if $x and $y refer to the same thing.
You can use this to recognize a reference that you have seen before:
sub index_of_object { my ($obj, @o_list) = @_; my $i; for ($i=0; $i < @o_list; $i++) { return $i if $o_list[$i] == $obj; } return; }
Or use it as an optimization:
sub obj_eq { my ($a, $b) = @_; return 1 if $a == $b; deep_compare($a, $b); }
Next | Copyright © 2003 M. J. Dominus |