in reply to Question on s///eg

Maybe you could take a look at Mastering Algorithms in Perl page 228, or install Steven McDougall's module Set::IntSpan. (I have done the former, maybe I will try the latter sometime).