in reply to Python 'is' command
G'day betmatt,
"... do exactly the same in Perl using a ref command in conjunction with '=='."
Depending on context, it may be worthwhile using ref to ensure you're actually comparing references; however, it's not needed for the comparison.
Instead of ==, I'd probably choose eq and do the comparison test like this:
$ref1 eq $ref2
Here's a short example:
$ perl -E ' my @x = ({}, []); my $y = $x[0]; say for @x, $y; say $_->[0] eq $_->[1] ? "Y" : "N" for [@x], [$x[0], $y]; ' HASH(0x600003a70) ARRAY(0x600076050) HASH(0x600003a70) N Y
— Ken
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Python 'is' command
by haukex (Archbishop) on Aug 15, 2019 at 09:53 UTC | |
by kcott (Archbishop) on Aug 16, 2019 at 07:02 UTC |