summaryrefslogtreecommitdiff
path: root/pod
diff options
context:
space:
mode:
author積丹尼 Dan Jacobson <jidanni@jidanni.org>2021-05-22 12:24:43 +0800
committerKarl Williamson <khw@cpan.org>2021-05-31 07:47:21 -0600
commit047a0ea72f583771e88b81f628b4e3468b794b37 (patch)
tree0711ec93c7b3020fdf16d1cc78c8bf5779f5bd3d /pod
parent696d6093e71c6a7024d554e90a1e1efd28da51d2 (diff)
downloadperl-047a0ea72f583771e88b81f628b4e3468b794b37.tar.gz
Add difference between <=> and cmp example
For https://github.com/Perl/perl5/issues/18742
Diffstat (limited to 'pod')
-rw-r--r--pod/perlop.pod7
1 files changed, 7 insertions, 0 deletions
diff --git a/pod/perlop.pod b/pod/perlop.pod
index 91db8b8a98..f07c6bc6f1 100644
--- a/pod/perlop.pod
+++ b/pod/perlop.pod
@@ -626,6 +626,13 @@ support C<"NaN">.)
Binary C<"cmp"> returns -1, 0, or 1 depending on whether the left
argument is stringwise less than, equal to, or greater than the right
argument.
+
+Here we can see the difference between <=> and cmp,
+
+ print 10 <=> 2 #prints 1
+ print 10 cmp 2 #prints -1
+
+(likewise between gt and >, lt and <, etc.)
X<cmp>
Binary C<"~~"> does a smartmatch between its arguments. Smart matching