in reply to Sort Says "not numeric" then sorts numeric anyway?

That actually came up with the 'right' answer -- numeric sorting, as well, plus no complaints from strict, but I have to admit I have no idea what I'm doing.
To clarify what you were attempting to do, and what gmax's code does do, you are getting the regex to pull off the digits at the start of each filename and sorting on that alone.

elbow
  • Comment on Re: Sort Says "not numeric" then sorts numeric anyway?

Replies are listed 'Best First'.
Re: Re: Sort Says "not numeric" then sorts numeric anyway?
by Hofmator (Curate) on Feb 11, 2003 at 08:51 UTC
    you are getting the regex to pull off the digits at the start of each filename and sorting on that alone

    No, that's not what Cody Pendant's regex does. His regex (/^d+/) looks for start of string, followed by at least one 'd' - no digit, that would be \d. And the way he uses it means that he makes a numerical compare on the truth value returned by the regex. The <=> forces scalar context, so the regex evaluates to true or false.

    -- Hofmator