Turns (148..153) to "148-53".
use 5.6.0; # XXX BUGGY # will be fixed shortly sub num2range { local $_ = join ',' => @_; s{(\d+?|)(\d+)(?:,\1((??{$++1})))+}{$1$2-$+}g; return $_; }

Replies are listed 'Best First'.
Re: List-to-Range (Advanced)
by Masem (Monsignor) on Jun 11, 2001 at 22:10 UTC
    Trivial addition on your end, and could easily be done by the user, but how about sort'ing @_ in the join, since the output only makes sense in this fashion. (Also, possibly grep'ing out non-positive values?)


    Dr. Michael K. Neylon - mneylon-pm@masemware.com || "You've left the lens cap of your mind on again, Pinky" - The Brain