[Date Prev][Date Next][Thread Prev][Thread Next] [Search] [Date Index] [Thread Index]

RE: [FWP] Formatting integer sets with ranges



> From: Prakash Kailasa [mailto:PrakashK@mail.com]
> Sent: Friday, January 07, 2000 14:59
> To: Yitzchak Scott-Thoennes
> Cc: fwp@technofile.org
> Subject: Re: [FWP] Formatting integer sets with ranges

...

> The reverse (expanding the range list) is much more compact:
> my $list = '1-3,5-6,8,10';
> print join ',', map { m/(\d+)\-(\d+)/ ?  ($1..$2) : $_; } split ",",
> $list;

$_ = '1-3,5-6,8,10';
s/-/../g;
$, = ',';
print eval;

--
Larry Rosler
Hewlett-Packard Laboratories
http://www.hpl.hp.com/personal/Larry_Rosler/
lr@hpl.hp.com>



==== Want to unsubscribe from Fun With Perl?  Well, if you insist...
==== Send email to <fwp-request@technofile.org> with message _body_
====   unsubscribe