in reply to splitting file with mutiple output filenames
What happens if you get the same value in two different matches?
open O, ">$r" or die $!;
--MidLifeXis