in reply to Gap-filling lists

you could use Set::Infinite or silimar that can do set logic ... pseduocode:
@lists =( (12..17), (25..42), (44..50) ); @gap_fillers = (m..n) - intersection( (m..n), @lists );
update can probably just do this:
$lists = Set::Infinite->new([12,17], [25,42], [44,50]); print Set::Infinite->new([m,n])->minus($lists);