Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl: the Markov chain saw

Re: Re: sort mechanism

by extremely (Priest)
on Apr 06, 2001 at 23:17 UTC ( #70563=note: print w/replies, xml ) Need Help??

in reply to Re: sort mechanism
in thread sort mechanism

No that doesn't work. The parens basically are no-ops there. a scalar is just a scalar. You would need @{$a} to explode the array.

update (GOOD band names =)

$you = new YOU;
honk() if $you->love(perl)

Replies are listed 'Best First'.
Re: Re: Re: sort mechanism
by McD (Chaplain) on Apr 06, 2001 at 23:32 UTC
    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?

    1. I shouldn't node before coffee, no matter what the hour.
    2. "Naked Scalars" would be a pretty good name for a rock and roll band.
    3. So would "Spaceship Operator."
    4. I still can't find where <=>'s behavior in list context is documented.
      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)

        Ok, then riddle me this:

        #!/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)]);


        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.


Log In?

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://70563]
[Corion]: Oof - "Anyway, if it is not obvious, please keep this discussion entirely confidential for now.", as seen on a public mailing list ;)
[Discipulus]: uh no choroba.. i do not practice much with online putyour image sites:can you suggest one (that possibly remove the pic after few days)?
[choroba]: Corion a bug report?
[choroba]: I have no idea :-( I used to post to, but they don't seem to feature "private" pictures in the free version now
[Discipulus]: dazz i'm not an experts but i think it would be possible
[Corion]: dazz: I think Image::Magick can "read" from an in-memory filehandle
[Corion]: choroba: No, some general admin discussion of how to handle (company) user accounts
[Discipulus]: might be it is necessary to pass the pic data like MIME::Base64:: encode( data..
[Discipulus]: if you have a jpeg data: or as wise Corion said IM ca n read directly your handle

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (10)
As of 2017-03-27 07:56 GMT
Find Nodes?
    Voting Booth?
    Should Pluto Get Its Planethood Back?

    Results (317 votes). Check out past polls.