Skip to Content
Perl 6 Deep Dive
book

Perl 6 Deep Dive

by Andrew Shitov
September 2017
Beginner
402 pages
9h 52m
English
Packt Publishing
Content preview from Perl 6 Deep Dive

Equivalency test operator

The eqv operator tests whether its two operands are equivalent. The term assumes that both operands are of the same type and contain the same value. The following examples demonstrate the work of the operator.

Two integer values are equivalent:

my $a = 42;my $b = 42;say $a eqv $b; # True

If one of the values is of another type, say a string, then the result is False, even if the value can be converted to the same integer:

my $a = 42;my $c = "42";say $a eqv $c; # False

The eqv operator works with arrays, as shown in the following code:

my @a = 1, 2, 3;say @a eqv [1, 2, 3]; # True

And, with more complex data structures, say, with nested arrays. Consider the following code snippet:

my @b = [[1, 3], [2, 4]];say @b eqv ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.
Start your free trial

You might also like

Perl Hacks

Perl Hacks

Chromatic, Damian Conway, Curtis Ovid Poe, Curtis (Ovid) Poe
Learning Perl 6

Learning Perl 6

brian d foy
Think Perl 6

Think Perl 6

Laurent Rosenfeld, Allen B. Downey
Pro Perl

Pro Perl

Peter Wainwright

Publisher Resources

ISBN: 9781787282049Supplemental Content