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

Re: [FWP] Formatting integer sets with ranges



Tushar Samant wrote:
> On Fri, 7 Jan 2000, John Porter wrote:
> >
> >sub int_ranges(@) {
> >  @_ = map { $_, '-' } sort { $a <=> $b } @_;
> >  pop;
> >  local $_ = join '', map {
> >    $_[$_] eq '-' && $_[$_-1] != $_[$_+1]-1 ? ',' : $_[$_]
> >  } 0 .. $#_;
> >  s/-[^-]-/-/g;
> >  $_
> >}
> 
> Sorry, I should have looked at this...

Sokay, mine has a serious bug, which I didn't see
until looking at your version.

> >  s/-[^-]-/-/g;

should be

	s/-[^,]+-/-/g;

-- 
John Porter


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