in reply to Re: sort an array
in thread sort an array

Thanks JD,

You're awesome. I tried both of them. The second one had a slight problem (the # needed to be escaped). They both do exactly what I need. I understand the first one better, so I might go with that one.

myffy

Replies are listed 'Best First'.
Re: sort an array
by jonadab (Parson) on Mar 19, 2006 at 10:35 UTC

    If you have trouble understanding the second one, you should look up the phrase "Schwartzian transform", when you have some free time, and read up on the technique. Becomming comfortable with this is something that will help you to think like an advanced Perl programmer. It's not just the technique itself, but the paradigms that it represents, notably, the idea of transforming a list, which is a very generally applicable thing and something Perl is very good for doing, so that it is something every really advanced Perl programmer needs to understand.

    However, ad interim, you should use the technique that you understand already.


    Sanity? Oh, yeah, I've got all kinds of sanity. In fact, I've developed whole new kinds of sanity. Why, I've got so much sanity it's driving me crazy.
Re^3: sort an array
by jdporter (Paladin) on Mar 19, 2006 at 22:27 UTC
    the # needed to be escaped

    I don't believe you. Pound signs never need to be escaped in regexes, and it shouldn't make any difference if they are or not. I invite you to show us your exact code — the one that behaves differently depending on whether the pound sign is escaped or not.

    We're building the house of the future together.
      Sorry, but you're wrong.
      $_ = "SomecomplexREhereandthenafoobar"; if (/Some complex RE here and then a # to ignore/x) { print "Escaping that # would have mattered\n"; }

        Yeah, o.k., /x. I lose. ;-) But I wonder - was the OP using /x?