Your skill will accomplishwhat the force of many cannot PerlMonks

### Re^2: What is the best way to compare variables so that different types are non-equal?

by jdporter (Canon)
 on Jul 20, 2009 at 11:21 UTC ( #781598=note: print w/replies, xml ) Need Help??

or

```sub comparifier {
no warnings 'uninitialized'; # because blessed() and reftype() can r
+eturn undef.
blessed(\$_[0]).reftype(\$_[0]).\$_[0]
eq
blessed(\$_[1]).reftype(\$_[1]).\$_[1]
}

• Comment on Re^2: What is the best way to compare variables so that different types are non-equal?

Replies are listed 'Best First'.
Re^3: What is the best way to compare variables so that different types are non-equal?
by ikegami (Pope) on Jul 21, 2009 at 17:56 UTC
That can result in false positives.
```my \$r = \@a;
print comparifier(\$r, "ARRAY\$r") ?1:0,"\n";   # 1

True enough.

```sub comparifier {
no warnings 'uninitialized'; # because blessed() and reftype() can
+ return undef.
my \$sep = pack 'N', rand 2**15;
blessed(\$_[0]) . \$sep . reftype(\$_[0]) . \$sep . \$_[0]
eq
blessed(\$_[1]) . \$sep . reftype(\$_[1]) . \$sep . \$_[1]
}

Between the mind which plans and the hands which build, there must be a mediator... and this mediator must be the heart.

Create A New User
Node Status?
node history
Node Type: note [id://781598]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others perusing the Monastery: (15)
As of 2018-06-22 17:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
Should cpanminus be part of the standard Perl release?

Results (124 votes). Check out past polls.

Notices?