Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl-Sensitive Sunglasses
 
PerlMonks  

Re: Humanized lists of numbers

by clintp (Curate)
on Jun 23, 2001 at 06:54 UTC ( [id://90920]=note: print w/replies, xml ) Need Help??


in reply to Humanized lists of numbers

May not be better, faster or stronger. Just a different way to do it. Works w/numbers, letters, and -- as an added bonus -- with strings like aa, ab, ac, ad, af reduced to "aa-ad,af".
sub human { my %h; @h{@_}=@_; $_=join(',',map { $h{$_}?$_:"*" } $_[0]..$_[-1]); s/(\w+),(\w+,)*(\w+)/$1-$3/g; s/,(\*,)+/,/g; split(","); }
I'm sure this can be golfed quite a bit, but I'm tired.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://90920]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others romping around the Monastery: (4)
As of 2024-04-25 14:28 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found