Um... right. I don't think I was completely clear - what I was
trying to point out was that <=> has different behavior when
comparing lists than when comparing scalars.
Although comparing two lists of a single scalar each is, as you said,
exactly like comparing the naked scalars.
So what have we learned?
- I shouldn't node before coffee, no matter what the hour.
- "Naked Scalars" would be a pretty good name for a rock and roll band.
- So would "Spaceship Operator."
- I still can't find where <=>'s behavior in list context is documented.
Peace,
-McD
| [reply] |
The equality operators apply scalar context to both sides.
Try this out and see. Operators apply context. I don't
think they often respond to it but with perl anything is possible =)
my @a = keys %env;
my @b = values %env;
my @c = ( "equal", "a > b", "b > a" );
print ($c[@a<=>@b]),$/;
No really, damn good band names... =)
--
$you = new YOU;
honk() if $you->love(perl) | [reply] [d/l] |
#!/usr/local/bin/perl -l
my @a = (1, 2, 3);
my @b = (1, 2, 4);
my @c = ( "equal", "a > b", "b > a" );
print ($c[@a<=>@b]);
print ($c[@b<=>@a]);
print ($c[(1, 2, 3)<=>(1, 2, 4)]);
print ($c[(1, 2, 4)<=>(1, 2, 3)]);
Produces:
equal
equal
b > a
a > b
Something about the difference between an array and a list, I suspect - a
distinction oft unclear in my mind, regardless of caffine levels.
Peace,
-McD
| [reply] [d/l] |