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 ( #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? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (5)
As of 2023-02-05 23:59 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    I prefer not to run the latest version of Perl because:







    Results (33 votes). Check out past polls.

    Notices?