3 attempts, the shortest weighing in at 77 characters(!), using japhys sort trick. I'm quite fond of the last two.

my @d=(1089,3,4,0,5,6,7,99,832,1087,831,1088,10000); print "\nfirst try\n\n"; @ary= boo(@d); print "@ary"; print "\n\nsecond try\n\n"; @ary=boo2(@d); print "@ary"; print "\n\nthird try (stringify)\n\n"; $list=boo3(@d); print $list; sub boo { # 1 2 3 4 5 6 7 + 8 9 A B C #234567890123456789012345678901234567890123456789012345678901234567890 +1234567890123456789012345678901234567890123456789012345 @_=sort{$a-$b}@_;$a[0]=$_[0];map{$q=$_[$_-1];$_[$_]==$q+1||do{$a[-1].= +"-$q";push@a,$_[$_]};$a[-2]=~s/(\d+)-\1/$1/}(1..$#_);@a } sub boo2 { # 1 2 3 4 5 6 7 + 8 #234567890123456789012345678901234567890123456789012345678901234567890 +123456789012345678 $_=join$",sort{$a-$b}@_;while(/(\d+)/g){$e=$1+1;s/($1) $e/$1-$e/;s/-\d ++-/-/}split" " } sub boo3 { # stringify # 1 2 3 4 5 6 7 + #234567890123456789012345678901234567890123456789012345678901234567890 +1234567 $_=join$",sort{$a-$b}@_;while(/(\d+)/g){$e=$1+1;s/($1) $e/$1-$e/;s/-$1 +-/-/}$_ }

In reply to How I learned to stop worrying and love $1. (boo) by boo_radley
in thread (Golf) Rangify Array by demerphq

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.