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

Re: [FWP] Formatting integer sets with ranges



Aw, I just figured out an improvement... screw that defined() test, and
here's another go:

  @parts = split /,/, $range;
  while ($_ = shift @parts) {
    $b = $_, next if !$b or !$t and $_ - $b > 1;
    $t = $_, next if !$t or $_ - $t == 1;
    $range =~ s/$b.*?$t/$b-$t/;
    ($b,$t) = ($_);
  }
  $range =~ s/$b.*?$t/$b-$t/ if $b and $t;

Still ick, though.

-- 

  MIDN 4/C PINYAN, USNR, NROTCURPI     http://www.pobox.com/~japhy/
  jeff pinyan: japhy@pobox.com     perl stuff: japhy+perl@pobox.com
  "The Art of Perl"               http://www.pobox.com/~japhy/book/      
  CPAN ID: PINYAN  http://www.perl.com/CPAN/authors/id/P/PI/PINYAN/
  PerlMonth - An Online Perl Magazine     http://www.perlmonth.com/


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