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

Re: [FWP] number ranges



On Mon, 14 May 2001, Jeff Pinyan wrote:

> On May 14, Andy Bach said:
> 
> >I've a test that gives back all the case mgrs and their number 
> >ranges, but it looks like:
> >andy: [01234]5
> >tina: [56789]5
[snip] 
> Are you asking "how can I turn a given set of numbers into a character
> class to match them?"

Uh, yes. That'd be a much better way of putting it, hmm, I get this?
@nos = qw(0 1 2 3 4 5);
$start = shift @nos;
$i = $start;
while  ( $_ = shift @nos ) {
last if $i++ + 1 != $_;
}
$end = $i;
print "$start - $end; ", join(", ", @nos), "\n";

a

Andy Bach, Sys. Mangler     	    CC:Mail andy bach at ~7ca-chicago
Internet: andy@wiwb.uscourts.gov    VOICE: (608) 264-5178 ex 5738, FAX 264-510

   UNIX *is* user friendly. It is just a bit selective about her friends.


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