in reply to eq or == with references
package Foo; sub new { return bless {}, shift } package main; my $x = new Foo; my $y = new Foo; print "number: ", int $x, " -- ", int $y, "\n"; print "string: $x -- $y\n";
Using == will always be true when both variables point to something, even though it's not the same object. It'll probably be treated the same as "Whatever" == "Something else".
Use eq, since that will stringify your objects into the form of PackageName=HASH(0xdeadbeef). If they point to the same object, they'll have the same memory address. (the 0xdeadbeef part). If that's the case, the two string will be equal.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
(tye)Re: eq or == with references
by tye (Sage) on Jul 08, 2001 at 05:53 UTC | |
by ariels (Curate) on Jul 08, 2001 at 12:23 UTC | |
by tye (Sage) on Jul 09, 2001 at 00:03 UTC | |
|
(CL) Re^2: eq or == with references
by CheeseLord (Deacon) on Jul 08, 2001 at 05:50 UTC | |
|
Re: (ar0n) Re: eq or == with references
by sierrathedog04 (Hermit) on Jul 08, 2001 at 07:35 UTC | |
by japhy (Canon) on Jul 08, 2001 at 19:38 UTC | |
by Dr. Mu (Hermit) on Jul 08, 2001 at 21:58 UTC | |
by tye (Sage) on Jul 09, 2001 at 10:22 UTC | |
by sierrathedog04 (Hermit) on Jul 09, 2001 at 15:30 UTC | |
by tye (Sage) on Jul 09, 2001 at 19:51 UTC | |
|