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

Re: [FWP] Formatting integer sets with ranges



Well, I *thought* I would score a coup with a feature from the latest 
development version, but it's not working the way I intended:

$_ = '1,2,3,5,6,7,8,9';
s#(\d+), ([\d,]+) (\d+) (?(?{print "/$1/$2/$3/\n"; $3 == $1 + 1 + $2 =~ 
tr/,//}) \b | x)#$1-$3#xg;
print "$_\n";

produces:

/1/2,3,5,6,7,8,/9/
/1/2,3,5,6,7,8,/8/
1-8,9

It appears that $3 is being changed with backtracking, but $2 isn't keeping 
up...


--
Peter Scott
Pacific Systems Design Technologies


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